相关属性列举:
noopener | Instructs the browser to open the link without granting the new browsing context access to the document that opened it — by not setting the Window.opener property on the opened window (it returns Note that when | |
noreferrer | Prevents the browser, when navigating to another page, to send this page address, or any other value, as referrer via the Referer: HTTP header.(In Firefox, before Firefox 37, this worked only in links found in pages. Links clicked in the UI, like "Open in a new tab" via the contextual menu, ignored this). | |
opener | Reverts implicit rel="noopener" addition on links with target="_blank" (See related HTML spec discussion, WebKit change, and Firefox bug discussion). |
如果你需要用a标签打开一个网页:
如果你需要用 a 标签打开一个标签页时,
你会使用 target='_blank' 这个属性,
此时你需要添加 rel='noreferrer noopener'
1. 使用rel=noopener
为了防止window.opener被滥用,在使用targrt=_blank时需要加上rel=noopener
<a href="www.baidu.com" target="_blank" rel="noopener" >
2.
rel=norefferrer
rel=noopener支持chrome49和opera36,不支持火狐,为了兼容需要加上rel=noreferrer
<a href="www.baidu.com" target="_blank" rel="noopener norefferrer" >