You can force a user's browser to open a new tab when clicking on a link by adding target="_blank" to it.
But you should always add rel="noreferrer" to it!
The reason and an explanation in a short thread. β
When a new tab opens, the page loaded gets access to the window.opener attribute. If the site has malicious code in it, it can use the opener property to redirect your page to another malicious site that might harm the user.
1/7
Adding rel="noreferrer" prevents that the window.opener property is accessible for the site linked to and additionally skips sending a Referer HTTP header to that page with your website's URL.
2/7
-> Explanation of the actual hack
When your browser opens a new tab after a user clicks a link, the window.opener attribute is set.
This is not only a string with the url, it is actually the window object of the other tab!
3/7
This fake site is a perfect copy of the original blog.
5/7
You'd probably not even realize that your other tab loads a fully different website.
It could contain malicious ads or popups that try to bring users to download malware, buy questionable products, or whatever else there is one could do online to cause harm.
6/7
When your links are protected with a rel of either noopener or noreferer, window.opener isn't set and can't be used for this type of hack.
You immediately protect all your users from falling into a nasty trap.
7/7
β’ β’ β’
Missing some Tweet in this thread? You can try to
force a refresh
1. Start your debugger 2. Trigger an action 3. Skip the first 10 breakpoints you forgot to remove last time 4. Realize you forgot to set a new breakpoint 5. Abort 6. Set a new breakpoint 7. Retrigger the action
ππ»
8. Sigh because you need to skip the 10 first breakpoints again 9. Realize you accidentally also skipped your new breakpoint 10. Retrigger the action 11. Skip and remove each of the first 10 breakpoints you forgot to remove once again 12. Stop at the right breakpoint
ππ»
13. Stare at your screen and think 14. Realize you should have set the breakpoint earlier 15. Abort 16. Set a new breakpoint 17. Retrigger the action 18. Stare at your screen again 19. Think and cry a little 20. Take a break