dongqian5639 2018-11-03 15:23
浏览 106
已采纳

返回第一个访问页面的按钮

Apologies if my question sounds like a newbie question...but I could not find an appropriate answer.

I am trying to create 2 back buttons on my website that would bring the visitor back : 1. to the very first page he visited on my website 2. to the previous site (not page) he visited - so the site that brought him to my site basically.

Is this feasible by any chance ? And if so, can you please share your insights on the way to do it ?

Many thanks in advance for any help !

  • 写回答

2条回答 默认 最新

  • dsj1961061 2018-11-03 15:43
    关注

    Maybe you can do something like this:

    $(document).ready(function() {
       var sessionIsNew = sessionStorage.getItem('sessionIsNew');
    
       if (sessionIsNew == null) {
          sessionStorage.setItem('sessionIsNew', 'false');
          sessionStorage.setItem('entryUrl', window.location.href);
       }
    
    }
    
    // On click to your back button:
    function backToEnrtryPage () {
        entryUrl  = sessionStorage.getItem('entryUrl');
    
        if (entryUrl != null) {
           window.location.href = entryUrl;
        }
    }
    

    More information about session in JavaScript

    https://developer.mozilla.org/de/docs/Web/API/Window/sessionStorage

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?