Reputation: 39
var Index;
var WeekTable=document.getElementbyId('MapList')
var w = window.open("");
The code above will open a new tab and then run this code:
w.document.writeln('HTML CODE GOES IN HERE FOR THE NEW PAGE');
I want to open this page in the same tab so the user can go back to that they were currently at.
Upvotes: 1
Views: 9199
Reputation: 11
From my understanding,since you want to carry the data from the previous page to the new page,it could be a good idea to store the required variables in a Javascript data structure that you can access later when the new page is loaded. You can create an array and push the data into it,and when you load the new page you will be able to access the required data.
Upvotes: 0
Reputation: 239220
... This seems weirdly trivial, but if you just want to redirect the user to a new page in the same tab, get rid of all your JavaScript and use a plain old <a>
tag, where the href
is set to the URL you want to go to. What you're describing is exactly the behaviour you get from a dead simple link, so I'm not sure why you don't just use one:
<a href="/mypage.html">Click Here</a>
If you have to run some JavaScript first, bind to the link's click
event, and then don't return false or run event.preventDefault()
inside your event handler, and the link will still be followed by the browser after your event handler is done.
If you must to do the actual "redirection" in JavaScript for some reason, assign the URL to window.location
instead of using window.open
:
window.location = "http://mysite.com/mypage.html"
Upvotes: 3