How to open link (a href) in new tab instead of loading url on same page?


Hello, I was working on HTML and would like to know how can I open anchor link ( HTML ) in a new tab instead of loading URL on the same page? Suppose this is my anchor tag HTML

<a href="URL">Open in new tabs</a>

Thanks.


Asked by:- jon
0
: 73 At:- 8/1/2018 1:23:39 PM
HTML open link in new tab html






1 Answers
profileImage Answered by:- Vinnu

You can simply use target="_blank" to open new tab and your link it, here is the sample HTML

<a href="URL" target="_blank">Open in new tabs</a>

In the above HTML target attribute specifies where to open the linked document, other values of target attribute is as below

Value Description
_blank Opens the linked document in a new window or tab
_self Opens the linked document in the same frame as it was clicked (this is default)
_parent Opens the linked document in the parent frame
_top Opens the linked document in the full body of the window
framename Opens the linked document in a named frame

If you want to open a button in new window you can use code below

<button class="btn btn-primary" onClick="window.open('http://www.example.com');">
     Open
</button>
2
At:- 8/2/2018 6:54:54 AM Updated at:- 8/2/2018 6:55:53 AM
excellent answer with proper details, thanks 0
By : jon - at :- 8/20/2018 3:30:13 PM





Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use