I have a combo-box which redirects a user to a specific page. To redirect, if I use
window.location.href = ...
when they hit back, it automatically redirects again. And if I use
window.location.replace (...)
they can't go back, because the history gets replaced with the new page.
I would have thought it's a fairly common scenario, so just wanted to ask if anyone knows a trick I'm missing?
Thanks
just check position of your syntax.
put it inside some function or event.
use below syntax :
window.location = "your_url";
Ok, finally figured it out. Turns out the jquery MultiSelect I'm using seems to preserve it's value so when I go 'back' into the browse, the MultiSelect kicks off an event as though it's been selected, which kicks off the redirect :( Fixed now by clearing the selected item and then redirecting.
尝试使用select的onchange事件,以便在用户更新值之前不会发生重定向。
<script language='javascript'>window.location='index.php'</script>
有用...
Try this way
before u do window.location.url do like..
if (!window.flag) window.location.url
window.flag=true;
So after u instructed for redict, ur resetting the flag.. so when u hit back buttion on the new page.. it goes to the old page.. but doesnt rediect
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.