You noticed that using target="_blank" for external links redirects users but may pose a security risk. How can you mitigate this risk while maintaining the functionality?

  • Add a JavaScript onclick event. 
  • Remove the target attribute altogether. 
  • Use only internal links. 
  • Use rel="noopener noreferrer" with the anchor tag. 
When using target="_blank", the new page can potentially gain access to the window object of the original page through the window.opener property, posing a potential security risk. Adding rel="noopener noreferrer" to the anchor tag prevents this behavior, protecting users from any potential security vulnerabilities. 
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *