Opening a URL in new tab using JavaScript, below snippet will do the trick
function OpenInNewTabWinBrowser(url) { var win = window.open(url, '_blank'); win.focus(); }
You could do it this way calling a direct function, or by adding an event listener to your DOM object.
Note: JavaScript, abbreviated as JS, is a high-level, interpreted programming language. It suits for development of client side behavior. Is JavaScript is easy to learn?. Yes, you can start with JavaScript basic programs in W3school website. There are many online courses to learn javascript in learning websites like Udemy.
Did this post help you?
Tutsplanet brings in-depth and easy tutorials to understand even for beginners. This takes a considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation:
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.
arvind kumar says
nice work
Vikram says
Good work, if someone stumbles upon this and want to open link in new tab using html, check
How to open link (a href) in new tab instead of loading url on same page?
Bappy says
Wow! this is working for me!