Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you open a popup (or tab) with <code>window.open</code>, the <code>load</code> event only fires once -- even if you "open" a new URL with the same window handle.</p> <p>To get the <code>load</code> listener to fire every time, you must close the window after each URL, and open a new one for the next URL.</p> <p>Because popups are asynchronous and you want to load these links sequentially, don't use a <code>for()</code> loop for that. Use the popup <code>load</code> status to "chain" the links.</p> <p>Here is the code to do that. It pushes the links onto an array, and then uses the <code>load</code> event to grab and open the next link. <a href="http://jsfiddle.net/LRFDD/1/" rel="nofollow"><strong>You can see the code in action at jsFiddle</strong>.</a> :</p> <pre><code>var searchButton = document.getElementById ('gmPopUpBtn'); var mytable = document.getElementById ('content').getElementsByTagName ('table')[0]; var myrows = mytable.rows; var linksToOpen = []; var mywin2 = null; function delnotifs () { var toRemove = document.getElementById ('find').value; for (var J = 0, L = myrows.length; J &lt; L; J++) { var matching = myrows[J].cells[0].innerHTML; if (matching.indexOf (toRemove) &gt; 0) { var links = myrows[J].cells[1].getElementsByTagName ("a"); linksToOpen.push (links[0].href); //-- Add URL to list } } openLinksInSequence (); }; function openLinksInSequence () { if (mywin2) { mywin2.close (); mywin2 = null; } if (linksToOpen.length) { var link = linksToOpen.shift (); mywin2 = window.open (link, "my_win2"); mywin2.addEventListener ('load', openLinksInSequence, false); } } searchButton.addEventListener ('click', delnotifs, true); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload