Where and why is the rel="noopener" attribute used?
Where and why is the rel="noopener" attribute used?
The rel="noopener"
attribute is used in HTML within the <a>
, <area>
, and <form>
elements. It is specifically applied to hyperlinks (defined by the <a>
tag) that open a target URL in a new browsing context, such as a new tab or window, which is typically specified using the target="_blank"
attribute.
rel="noopener"
The primary purpose of the rel="noopener"
attribute is to enhance security by preventing the newly opened page from accessing the window.opener
property of the page that opened it. This property could otherwise allow the new page to control the original page, leading to potential security risks such as phishing attacks. By setting window.opener
to null
, the rel="noopener"
attribute effectively severs any connection between the two pages, ensuring that the originating document remains secure from potential malicious tampering by the opened page[1][2][3][6].
Here is how the rel="noopener"
attribute is typically used in an HTML anchor tag:
<a href="https://example.com" target="_blank" rel="noopener">Visit Example</a>
In this example, clicking the link opens "https://example.com" in a new tab, and the rel="noopener"
attribute prevents the new tab from accessing the window.opener
property of the original page.
From an SEO perspective,...
middle
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào