View Full Version : Bit of a long shot but can javascript shut all open tabs....

03-28-2009, 11:23 AM
I use a suppliers website to check availability of the products on our website.

Basically I have created a web page with a few hundred links on it to the suppliers stock check page for each product. I have also put a link at the top of the page "OPEN ALL LINKS" which opens every link on my stockchecker page in a new tab. I use this javascript code to open all the links

function popWindows() {
if (!document.getElementsByTagName) return false;

var allAnchors = document.getElementsByTagName("a");

for (i=0; i<allAnchors.length; i++) {
var thisLink = allAnchors[i].getAttribute("href");

Once all the tabs are open I then manually close each one, making a note of any out of stock items.

Heres the long shot.....

What I would like to do is either adapt the current code so it automatically opens but then closes any link where the text "available now" is found leaving only the links with " out of stock" open.

or a new piece of code on a new tab that when clicked searches through all open tabs and if the text "available now" is found it closes that tab.

Is this possible???


03-29-2009, 04:55 AM
Only way would be to change your internet security options to let JavaScript to talk to other domains.

You really should look into a serverside langauge that can scrap the sites and give you the info you need.


04-01-2009, 10:04 AM
Thanks for the tip about using a screen scraper. I have found a pretty cheap bit of software that does just the job.