html中a标签rel=”nofollow noopener noreferrer”含义

  超链接 target=”blank” 要增加 rel=”nofollo […]

  超链接 target=”blank” 要增加 rel=”nofollow noopener noreferrer” 来堵住钓鱼安全漏洞。如果你在链接上使用 target=”blank”属性,并且不加上rel=”noopener”属性,那么你就让用户暴露在一个非常简单的钓鱼攻击之下。

当你浏览一个页面点击一个a标签连接 <a href=”www.baidu.com” target=”_blank”> 跳转到另一个页面时,

在新打开的页面(baidu)中可以通过 window.opener获取到源页面的部分控制权, 即使新打开的页面是跨域的也照样可以(例如 location 就不存在跨域问题)。

rel=noopener 新特性

<a href=”www.baidu.com” target=”_blank” rel=”noopener noreferrer”></a>

在chrome 49+,Opera 36+,打开添加了rel=noopener的链接, window.opener 会为null。在老的浏览器中,可以使用 rel=noreferrer 禁用HTTP头部的Referer属性,使用下面JavaScript代替target='_blank' 的解决此问题:

var otherWindow = window.open('http://keenwon.com');
otherWindow.opener = null;
otherWindow.location = url;

使用 window.open 打开页面,手动把opener设置为null。

[pwdshow pwd=”密码”]密码可见内容[/pwdshow]

[loginshow]登录可见的内容[/loginshow]

版权声明
文章标题:html中a标签rel=”nofollow noopener noreferrer”含义
文章链接:https://blog.chiyuba.com/houduanjishu/284.html
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布,转载或引用请注明出处。
温馨提示:本文最后更新于 2021年12月31日,部分内容可能存在时效性,请注意甄别。

相关推荐

更多教程
C# 库开发记录 其他 C# 库开发记录

  json转化编码设置 re...

4 浏览
世界,您好! 后端技术 世界,您好!

[title-plane title=&...

2 浏览
8、ThinkPHP6实战开发高大上企业站(TP6)之常用的命令 php 8、ThinkPHP6实战开发高大上企业站(TP6)之常用的命令

前言 今天给大家带来一些常用的php命令...

7 浏览

评论