admin管理员组文章数量:1287791
With the code below I can make a 'back' button, but is there a way of making the link require that the last page was part of the current site?
$(document).ready(function(){
$('a.back').click(function(){
parent.history.back();
return false;
});
});
If the last page wasn't part of the current site then ideally id like to be able to specify a backup link.
Thanks
With the code below I can make a 'back' button, but is there a way of making the link require that the last page was part of the current site?
$(document).ready(function(){
$('a.back').click(function(){
parent.history.back();
return false;
});
});
If the last page wasn't part of the current site then ideally id like to be able to specify a backup link.
Thanks
Share Improve this question edited Mar 30, 2011 at 18:21 zzzzBov 179k56 gold badges327 silver badges371 bronze badges asked Mar 30, 2011 at 18:20 EvanssEvanss 23.2k100 gold badges322 silver badges555 bronze badges 2- 2 Do you have a good reason for trying to mimic behavior already performed by the browser? – zzzzBov Commented Mar 30, 2011 at 18:22
- The short answer is 'because my client has asked me'. Its for a 'continue shopping' link so it should go back to the previous category. The issue is that there are 2 different potential categories for each product. – Evanss Commented Mar 30, 2011 at 18:31
2 Answers
Reset to default 8How about using document.referrer
?
$(document).ready(function(){
$('a.back').click(function(){
if(document.referrer.indexOf(window.location.hostname) != -1){
parent.history.back();
return false;
}
});
});
Please don't do this.
But you could use a cookie
psuedo code
if !cookie_exists()
disable_back_button()
create_cookie()
Then delete the cookie when the user leaves.
Referrer can be edited, so I don't remend that
but I also don't remend doing this at all, its annoying.
本文标签: JavascriptjQuery back buttonso long as last page was part of current siteStack Overflow
版权声明:本文标题:JavascriptjQuery back button - so long as last page was part of current site? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741324877a2372416.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论