Javascript / jQuery back button - so long as last page was part of current site?

非 Y 不嫁゛ 提交于 2019-12-03 01:41:06

How about using document.referrer?

$(document).ready(function(){
    $('a.back').click(function(){
        if(document.referrer.indexOf(window.location.hostname) != -1){
            parent.history.back();
            return false;
        }
    });
});
Galen

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 recommend that

but I also don't recommend doing this at all, its annoying.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!