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 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)