Updated_noopener_noreferrer_definitions.md #29057
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have Simplified the Definitions of
noopener
andnoreferrer
definitions with added examples.The
noopener
value prevents the opened link from gaining access to the webpage from which it was opened.noopener
: Thenoopener
attribute ensures that a link opened in a new tab or window cannot interact with or access the original page. Without it, the new page can use JavaScript to manipulate the original page, which poses a security risk.The
noreferrer
value prevents the opened link from knowing which webpage or resource has a link (or 'reference') to it. Thenoreferrer
value also includes thenoopener
behaviour and thus can be used by itself as well.For example:
"Open Example"
In this code:
target="_blank": opens the link in a new tab.
rel="noopener": prevents the new tab from accessing the original page, ensuring security.
Without
noopener
, the new tab could use JavaScript to interact with the original page, which is unsafe.noreferrer
: Thenoreferrer
attribute provides both privacy and security. It prevents the new page from knowing where the user came from (hiding the referrer) and also includes the behavior ofnoopener
, preventing the new page from accessing the original page.For example:
"Visit Example"
In this example:
target="_blank": opens the link in a new tab.
rel="noreferrer": ensures the new page cannot see the referring page’s address (privacy) and prevents it from accessing the original page (security).
By using rel="noreferrer", you automatically get the benefits of both privacy and security.