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

前端 未结 2 896
感情败类
感情败类 2021-02-04 18:22

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).rea         


        
2条回答
  •  无人及你
    2021-02-04 18:55

    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;
            }
        });
    });
    

提交回复
热议问题