https跳转到http无法获取referrer解决方式

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38373006/article/details/81180233

从https跳转到http网站时,为了用户隐私安全信息,浏览器默认不传送referrer

http协议规定

Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.

解决方式:

在https页面中添加meta标签

<meta content="always" name="referrer"/>

在要接取的页面js中使用document.referrer即可获取

猜你喜欢

转载自blog.csdn.net/weixin_38373006/article/details/81180233