Greetings, there is a button that performs the action you need to implement so that by clicking on it in addition, several links open in new tabs, but the user remained on the site. Searched the forums did not find .. There is a button

<input type="submit" class="btn btn-primary btn-lg" value="Get reward!"> 

there is a script

 <!-- MBT MULTIPLE LINKS CODE --> <script type='text/javascript'> function links() { var http = "http://sh.st22/fv2129u"; var win1 = window.open(http); var http = "http://sh.st22/fX523jF"; var win1 = window.open(http); var http = "http://sh.st22/f1X54YP"; var win1 = window.open(http); var http = "http://sh.st22/fX495Pm"; var win1 = window.open(http); } </script> 

but it works only on the element of the form:

 <a rel="nofollow" href="javascript:links()">Текст</a> 

How do I make it work for:

 <input type="submit" class="btn btn-primary btn-lg" value="Get reward!"> 

2 answers 2

Generally like this, but still not all supported. How to open and open whether the browser settings decide.

 function newTab(src) { if($.browser.mozilla||$.browser.msie){ window.open(src,'_blank'); }else{ var a = document.createElement("a"); a.href = src; a.target = "_blank"; var evt = document.createEvent("MouseEvents"); evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, false, true, 0, null); a.dispatchEvent(evt); } } function links(){ var links = [ "http://sh.st22/fv2129u","http://sh.st22/fX523jF"]; for(i=0;i<links.length;i++){ newTab(links[i]); } } 

    It will not work ?

    UP: <input type="submit" class="btn btn-primary btn-lg" value="Get reward!" onclick="links();return false;"> <input type="submit" class="btn btn-primary btn-lg" value="Get reward!" onclick="links();return false;"> not suitable?

    • Action does not happen - Bred