3

I have a variable defined in my script code that says:

    <script>
...
       var Path = "~/LogInfo.aspx" + ID;
...
    </script>

And I want to be able to use this variable in my html code:

<meta http-equiv="Refresh" content="3; url='Path'">

How would I do this?

user3194708
  • 87
  • 1
  • 10

1 Answers1

3

The meta refreshes are only read at page load. If you add one after page load, or try to change one after page load, it will not work. So you can't do it with Javascript because javascript runs on the client, after page load. So you have to set the path on the serverside. If you need logic to determine between different possible paths, it will have to be on the server with a server-side language.

Example with JSP:

 <%
 int x = pullXfromSomewhere();
 String path = "index" + x + ".jsp";
 %>
 <meta http-equiv="Refresh" content="3; url='<%=path%>'">
developerwjk
  • 8,619
  • 2
  • 17
  • 33
  • If I need the path to contain info from the url how would I do this? – user3194708 Mar 14 '14 at 13:43
  • Do you mean from the querystring? like `http://server/index.jsp?id=5` you want to use that id. Something like `path = "index" + request.getParameter("id") + ".jsp";` – developerwjk Mar 14 '14 at 17:23