zetlnd

открывать несколько ссылок по одной кнопке

Aug 1st, 2021 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <button id="searchBtn">Кнопка</button>
  2.  
  3.  
  4. <script>
  5. var linkList = [
  6. 'http://www.3dmir.ru/index.php?id=search&text=bump',
  7. 'http://www.3dmir.ru/index.php?id=search&text=displacement'
  8. ];
  9.  
  10. function init(){
  11. var searchBtn = document.getElementById("searchBtn");
  12. searchBtn.addEventListener("click",search);
  13. }
  14.  
  15. function search(){
  16. for(var i = 0; i < linkList.length; i++) {
  17. var a = document.createElement("a");
  18. a.href = linkList[i];
  19. a.target="_blank"
  20. a.click();
  21. }
  22. }
  23.  
  24. window.addEventListener("load", init);
  25. </script>
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. ---
  35.  
  36. <button id="open_all">Клик</button>
  37.  
  38. <script>
  39. window.onload = function() {
  40. document.getElementById('open_all').onclick = f_open_all;
  41.  
  42. function f_open_all() {
  43. window.open("ссылка1");
  44. window.open("ссылка2");
  45. window.open("ссылка3");
  46. }
  47. }
  48. </script>
Add Comment
Please, Sign In to add comment