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.
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.
Share Improve this question edited Aug 29, 2013 at 19:14 kender 87.4k26 gold badges105 silver badges146 bronze badges asked Aug 29, 2013 at 19:09 user2722517user2722517 393 silver badges12 bronze badges 3-
1
Do you mean open a new tab in the same window? So you want
window.open
to force open a new tab instead of window? – Travis Commented Aug 29, 2013 at 19:10 - 1 So, you want to redirect them to a new page? – gen_Eric Commented Aug 29, 2013 at 19:11
- window.open will open a new tab. I want to do the same thing but keep the user in the same tab so they can go back to the previous page – user2722517 Commented Aug 29, 2013 at 19:13
2 Answers
Reset to default 3... 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./mypage.html"
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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745259475a4619143.html
评论列表(0条)