简体   繁体   中英

Javascript hyperlink(.link) open in new tab

I had used a javascript .link to generate a hyperlink as below

$element.html(indicator.link(domain));

But the URL opens at the same page as originally the link clicked. How can I make it to be opened in new tab?

try this:

 function myFunction() { var str = "Free Web Building Tutorials!"; var result = str.link("https://www.google.co.in"); document.getElementById("demo").innerHTML = result; } 
 <button onclick="myFunction()">Try it</button> <p id="demo"></p> 

function setMyAdd() { window.open(myLink); }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM