Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript-How to implement target=_blank in a simple link [duplicate]

So, this is my code:

function link1() { window.location.href="Example"; }

How do i achieve the _blank function in JS?

Cheers

(Note: I am not using a library, nor am i intending to atm)

like image 672
sanorpetro Avatar asked Aug 21 '26 09:08

sanorpetro


1 Answers

window.open will do the trick.

function link1()
{ 
   window.open("http://www.example.com");
}
like image 186
Mark Avatar answered Aug 23 '26 00:08

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!