当前位置:网站首页>Always use "noopener" or "noreferrer" for links that open in a new tab
Always use "noopener" or "noreferrer" for links that open in a new tab
2022-08-01 23:07:00 【Ziwei front end】
In order to open the link in a new tab, we use the
`target="_blank"`
attribute.However, if you don't know them, it can cause some problems.First, newly opened tabs use the same process as the opener.Therefore, it may slow down your page.More importantly, the new tab can access the
`window.opener`
object of the `window`
open page through the object.Suppose the new tab executes the following code:window.opener.location = 'http://fake.website.here';
As the code suggests, it redirects the original tag to a fake website.What would happen if a fake website had the same user interface as the real website?Since the user has already opened it, they may not realize that the website they are viewing is not real.
Add
`rel="noopener"`
to fix the problem.Good to know that there is a
`rel="noreferrer"`
attribute.Not only does it fix an issue where `noopener`
does exist, but it also prevents `Referer`
headers from being sent to new tabs.Some modern browsers (such as Chrome 88+) automatically add this behavior when it is missing from
`noopener`
.However, it is still recommended to add `rel="noopener"`
or `rel="noreferrer"`
to avoid security and performance issues in older browsers.边栏推荐
- E - Integer Sequence Fair
- 加载字体时避免隐藏文本
- xctf attack and defense world web master advanced area webshell
- 对于在新标签页中打开的链接,始终使用“noopener”或“noreferrer”
- 论文解读(GSAT)《Interpretable and Generalizable Graph Learning via Stochastic Attention Mechanism》
- 程序员如何优雅地解决线上问题?
- SRv6 L3VPN的工作原理
- 添加大量元素时使用 DocumentFragments
- 简单3D渲染器的制作
- 软技能之UML图
猜你喜欢
随机推荐
PAM Palindromic Automata
Three, mysql storage engine - building database and table operation
美赞臣EDI 940仓库装运订单详解
程序员如何优雅地解决线上问题?
小程序毕设作品之微信美食菜谱小程序毕业设计成品(6)开题答辩PPT
excel edit a cell without double clicking
Postman 批量测试接口详细教程
xctf攻防世界 Web高手进阶区 web2
A. Doremy‘s IQ-- Codeforces Round #808 (Div. 1)
Nacos配置中心之加载配置
D - Linear Probing- 并查集
13、学习MySQL 分组
System availability: 3 9s, 4 9s in SRE's mouth... What is it?
分享10套开源免费的高品质源码,免费源码下载平台
npm包【详解】(内含npm包的开发、发布、安装、更新、搜索、卸载、查看、版本号更新规则、package.json详解等)
联邦学习入门
PHP算法之最接近的三数之和
From 0 to 1: Design and R&D Notes of Graphic Voting Mini Program
excel change cell size
SQL Server(设计数据库--存储过程--触发器)