How can I open two urls in two tabs in a single click? [duplicate]

可紊 提交于 2019-12-11 19:23:33

问题


I have 2 urls
http://www.example.com
and
http://www.nana.com

If I click the below link the above 2 urls should open in two tabs..
a href="#">Click /a

May anyone help me to acheive this one?

Thanks In advance


回答1:


Try something like this :

<a id="test" href="#"> CLick </a>
<script type="text/javascript">

  document.getElementById("test").onclick = function(){
   window.open("http://www.google.com",'_blank');
   window.open("http://www.p3php.in",'_blank');
}
</script>



回答2:


This should work:

<a href="http://www.example.com" onclick="window.open('http://www.nana.com')">Click</a>



回答3:


Try something like this :

<a href="#" onclick="window.open('http://google.com');
    window.open('http://yahoo.com');" >Click</a>



回答4:


Better way to do it

HTML:

<a id="link">Click me!!</a>

JS:

var link = document.getElementById("link");

link.onclick = function() {
    window.open("http://yahoo.com");
    window.open("http://google.com");
};

Cheers!!




回答5:


hope this works

<html>
<script>
function pageloader()
{

 window.open("http://www.example.com", '_blank');
 window.open("http://www.google.com", '_blank');

}

</script>
<body>
<a href="#" onclick="pageloader();">Click here </a>


</body>
</html>

goodluck!



来源:https://stackoverflow.com/questions/18372865/how-can-i-open-two-urls-in-two-tabs-in-a-single-click

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!