document.referrer是否与浏览器兼容? [英] Is document.referrer cross browser compatible?

查看:113
本文介绍了document.referrer是否与浏览器兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用document.referrer进行非正式的引荐来源检查。这个元素是否与浏览器兼容?尝试引用文档对象时,是否会有任何浏览器抛出错误?

I'd like to use document.referrer for an informal referrer check. Is this element cross browser compatible? Will any browser throw an error when trying to reference the document object?

推荐答案

document.referrer 属性在DOM规范中描述:

The document.referrer property is described in the DOM spec:

http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-95229140

所以跨浏览器支持 。但是,您可以轻松检测实现是否支持此属性,如

So it should be supported cross-browser. However, you can easily detect if the implementation does support this property like

if( 'referrer' in document ) { 
    console.log(document.referrer);
}

这篇关于document.referrer是否与浏览器兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆