tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_multiple_popups.html (1797B)


      1 <!DOCTYPE html>
      2 <html>
      3 <body>
      4  <button onclick="openPopups();" id="openPopups">open popups</button>
      5  <button onclick="openNestedPopups();" id="openNestedPopups">open tested popups</button>
      6  <button onclick="openPopupAndClick();" id="openPopupAndClick">open popups and click</button>
      7  <button onclick="closeAllWindows();" id="closeAllWindows">close all windows</button>
      8  <button onclick="openPopupInFrame();" id="openPopupInFrame">open popup in frame</button>
      9  <input type="text" id="input" />
     10  <script>
     11 let windows = [];
     12 
     13 function openPopups() {
     14  windows.push(window.open('empty.html', '_blank', 'width=100,height=100'));
     15  windows.push(window.open('empty.html', '_blank', 'width=100,height=100'));
     16 }
     17 
     18 function openNestedPopups() {
     19  var w = window.open('empty.html', '_blank', 'width=100,height=100');
     20  windows.push(w);
     21  windows.push(w.open('empty.html', '_blank', 'width=100,height=100'));
     22 }
     23 
     24 var recursion = false;
     25 function openPopupAndClick() {
     26  windows.push(window.open('empty.html', '_blank', 'width=100,height=100'));
     27  if (!recursion) {
     28    recursion = true;
     29    document.getElementById("openPopupAndClick").click();
     30  }
     31 }
     32 
     33 function openPopupInFrame() {
     34  let iframe = document.createElement("iframe");
     35  iframe.style.display = "none";
     36  document.body.appendChild(iframe);
     37  windows.push(iframe.contentWindow.open('empty.html', '_blank', 'width=100,height=100'));
     38  iframe.remove();
     39 }
     40 
     41 function closeAllWindows() {
     42  windows.forEach(w => {
     43    try {
     44      w.close();
     45    } catch(e) {}
     46  });
     47 }
     48 
     49 if (location.search.includes("openPopups")) {
     50  let id = setInterval(() => {
     51    if (document.getElementById('start')) {
     52      clearInterval(id);
     53      openPopups();
     54    }
     55  }, 500);
     56 }
     57 
     58 document.getElementById("input").onmouseup = _ => {
     59  openPopups();
     60 }
     61  </script>
     62 </body>
     63 </html>