`
forhope
  • 浏览: 360374 次
  • 性别: Icon_minigender_1
  • 来自: 帝都
社区版块
存档分类
最新评论

location.href跳转时不同浏览器对Referer的设置

 
阅读更多
Your post title shows that you want to change the current page programmatically using JavaScript but still having the HTTP referrer provided (from what I understood, using a <a> tag is just for a test case).

You need to be aware of cross-browser issues:

    The HTTP referrer header (HTTP-Referer) is set when changing window.location.href under the following browsers:
        MSIE 9 (but probably any version above 9)
        Firefox (at least 3.0, 3.5, 4.0, 5.0, but most probably all versions)
        Chrome (at least 9, but most probably all versions)
        Safari (at least 5, but most probably all versions)
        Opera (at least 11, but most probably all versions)
    MSIE (at least 6, 7, \8): the referrer is not set when changing window.location.href
    Firefox (at least 3.0, 3.5, 4.0): the click function does not exist (this is why some pseudo-solutions are based on myLink.click())
    Firefox 5 : the click function exists under Firefox 5 but does not change the window location, so all the methods relying on the existence of the myLink.click() method will not work. Calling myLink.onclick() or myLink.onClick() raise an error ("onclick is not a function"), so solutions based on these calls will not work.

var navigatorName = "Microsoft Internet Explorer";
      if (navigator.appName == navigatorName){                //IE浏览器在location.href时不会设置referer
    	    var referLink = document.createElement('a');
    	    referLink.href = url;
    	    document.body.appendChild(referLink);
    	    referLink.click();
    	} else {
    	    location.href = url;
    	}
分享到:
评论

相关推荐

    IE下通过a实现location.href 获取referer的值

    IE下采用[removed].href方式跳转的话,referer值为空在标签a里面的跳转的话referer就不会空,下面是具体的实现代码

    获得当前页面的url

    window.location.href location.search; //获取url中"?"符后的字串 document.referrer 获取来路的url,相当于php的$_SERVER['HTTP_REFERER']。 encodeURIComponent() 对url进行转定义,相当于php的urlencode()...

    javascript操作referer详细解析

    本篇文章主要是对javascript操作referer进行了详细的介绍,需要的朋友可以过来参考下,希望对大家有所帮助

    nginx利用referer指令实现防盗链配置

    location ~* \.(gif|jpg|png|webp)$ { valid_referers none blocked domain.com *.domain.com server_names ~\.google\. ~\.baidu\.; if ($invalid_referer) { return 403; #rewrite ^/ ...

    完美兼容各大浏览器获取HTTP_REFERER方法总结

    发现一个关于浏览器兼容的问题,当用JS 执行代码 [removed].href=”http://www.jb51.net” 来进行跳转的时候,Firefox 可以获取到到HTTP_REFERER页面,但是在IE中这一项为空

    request.getHeader("referer")防盗链

    HTTP headers是HTTP请求和相应的核心模块,它承载了关于客户端浏览器、请求页面、服务器等相关信息。Referer是HTTP头中的一个属性,告诉服务器我是从哪个页面链接过来的。

    safemanage,Jquery,js.

    safemanage,Jquery,js.

    mmturkey:一个微型库,用于将外部网页中的数据发送到亚马逊的Mechanical Turk

    一个很小的库,用于将数据从外部网页发送到Amazon的... )如果它们不在location.href ,则脚本还会尝试document.referer ,因此可以想象地将任务拆分为多个两个不同的页面。 当找不到这些属性时,它们将设置为空字符

    关于request.getHeader(Referer)的问题探讨

    我在某些页面中,有某几个按钮,分别用来跳转到action.do?method=m 但是,我是用 warpLoaction(”url”);这个来链接过去的,结果,我在火狐浏览器中,可以正确的 获取上次访问的页面,在IE6下却获取不到。后来去...

    关于request.getHeader(&quot;Referer&quot;)的问题探讨

    request.getHeader("Referer")获取上次访问的URL链接,在什么情况下他会出现问题,下面为大家分享下,感兴趣的朋友不要错过

    referer-mod:Web Extension修改HTTP请求中的Referer标头

    Referer-mod Referer Modifier是Firefox的Web扩展,用于修改HTTP请求中的Referer标头和匹配的Javascript document.referrer属性。 对于每个目标域,可以配置以下五个操作之一: 保留:请勿修改引荐来源网址 修剪:...

    referer.txt

    html跳转阻断referer,跳转后台的页面获取不到来源页面的referer,某些特定场景下很实用

    noreferrer去除网页跳转refer

    noreferrer去除网页跳转refer,使得跳转页面refer为空

    selenium-referer:在使用Python和WebDriver的Selenium测试中添加Referer请求标头的示例

    具有自定义Referer标头的Python Selenium测试 有时,当用户来自不同来源/搜索引擎时,网站需要具有不同的行为。 在我的用例中,我们的网站必须设置一个跟踪Cookie,该跟踪Cookie对于来自Google,AOL,Yahoo或MSN的...

    解决js下referer兼容各大浏览器的方法

    方法:利用js的 document.referer 方法可以准确地判断网页的真实来路。 目前百度统计,google ads统计,CNZZ统计,都是用的这个方法。防盗链也很简单了,js里判断来路url如果不是本站不显示图片。 众所周知,我们web...

    ctf总结.md

    burpsuite,浏览器代理设置教程抓了包后右键放到repeater里,点go可以进行发包测试,用完Burpsuite过后,要正常上网的话,要把代理关了。 浏览器插件改包的话,(有视频) 找flag:在请求头,响应头尝试实验室:key究竟...

    PHP利用REFERER根居访问来地址进行页面跳转

    主要是根据referfer判断来源,然后跳转到制定页面,以防出现了无法访问页面,用户体验不好

    Express URL跳转(重定向)的实现方法

    Express是一个基于Node.js实现的Web框架,其响应HTTP请求的response对象中有两个用于URL跳转方法res.location()和res.redirect(),使用它们可以实现URL的301或302重定向。 res.location(path) res.location(path) ...

Global site tag (gtag.js) - Google Analytics