Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    74
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Bit of a long shot but can javascript shut all open tabs....

    Hi
    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

    Code:
    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");
    		window.open(thisLink);
    	}
    }
    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???

    Robbiez

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    74
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Hi
    Thanks for the tip about using a screen scraper. I have found a pretty cheap bit of software that does just the job.
    Rob


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •