【问题标题】:how to check and validate the url of a previous visit to our page using jquery如何使用 jquery 检查和验证以前访问我们页面的 url
【发布时间】:2021-11-13 09:17:59
【问题描述】:

我有一个拼图形式的静态页面,我想使用参数“if else”,以便在从我想要的站点单击我的页面的 url 时可以查看我的页面。例如,简单。

如果我的结果页面是通过这个网站访问的。

https://example.com

所以 https://example.com/result 可以看到。

但是,如果我的页面是通过这个网站访问的

https://example-2.com

或者不通过example.com网站,或者不通过https://example.com直接访问example.com/result链接

所以 https://example.com/result 什么都不显示。

我可以在我的静态页面上实现这样的系统吗?如果 else jquery 只使用参数?

【问题讨论】:

    标签: javascript jquery url static-pages


    【解决方案1】:

    你可以使用

    document.referrer
    

    The Document.referrer property returns the URI of the page that linked to this page.(MDN)

    你可以这样做

    if (document.referrer != ""){
        if (new URLPattern(document.referrer).hostname === new URLPattern(window.location.origin).hostname){
            //show result 
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-20
      相关资源
      最近更新 更多