zoukankan      html  css  js  c++  java
  • 返回当前文档的文档的url

     1 HTML DOM referrer 属性
     2 HTML DOM Document 对象
     3 
     4 定义和用法
     5 referrer 属性可返回载入当前文档的文档的 URL。
     6 
     7 语法
     8 document.referrer
     9 说明
    10 如果当前文档不是通过超级链接访问的,则为 null。这个属性允许客户端 JavaScript 访问 HTTP 引用头部。
    11 
    12 实例
    13 <html>
    14 <body>
    15 
    16 The referrer of this document is:
    17 <script type="text/javascript">
    18 document.write(document.referrer)
    19 </script>
    20 
    21 </body>
    22 </html>
     1 [html] view plain copy
     2 var prevLink = document.referrer;  
     3 if($.trim(prevLink)==''){  
     4     location.href = 'www.example.com/index.html';  
     5 }else{  
     6     if(prevLink.indexOf('www.example.com')==-1){    //来自其它站点  
     7         location.href = 'www.example.com/index.html';  
     8     }  
     9     if(prevLink.indexOf('register.html')!=-1){      //来自注册页面  
    10         location.href = 'www.example.com/index.html';  
    11     }  
    12     location.href = prevLink;  
    13 }  
  • 相关阅读:
    JavaScript中的Date对象
    补零函数和随机数函数
    设置与获取自定义属性
    eval()
    获取DOM元素样式
    do{}while() 循环
    ++ 运算符
    switch 语句
    git
    webpack
  • 原文地址:https://www.cnblogs.com/yangguoe/p/8819050.html
Copyright © 2011-2022 走看看