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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Whats wrong with my script?!

    I need some help real quick, I posted a question a few hours ago about this but after a couple hours of tinkering I got it mostly done.

    Below, arrays 0 thru 6 are the same web address. Array 7 is a different address. I need the script to open all seven one a couple seconds after another which it does, but I need it to close them after they have only been open about 5 seconds or open them all in the same window, which would be prefered. If they are opened in the same window they have to have time to load so the load of the next page needs to be delayed about 4 seconds or so.

    Lastly, I need the script to loop over and over, prefererably around 5 times. Anyone want to point out my mistake on getting the window to close 5 seconds after it opens or getting it to open in the same window? Also getting the script to run 5 times in a row?

    <HEAD>
    <SCRIPT language="JavaScript">
    <!--
    function display_go()
    {
    var go= new Array(8)
    go[0]="website address 1";
    go[1]="website address 1";
    go[2]="website address 1";
    go[3]="website address 1";
    go[4]="website address 1";
    go[5]="website address 1";
    go[6]="website address 1";
    go[7]="website address 2";
    var x=0;
    for (x=0; x<8; x++)
    {
    preview = window.open(go[x]);
    setTimeout("preview.close();", 5000);
    }
    }
    //-->
    </SCRIPT>
    </HEAD>
    <BODY onLoad="display_go();">
    Last edited by mb116; 01-12-2007 at 10:31 AM.

  • #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
    If those address values are not in your domain, you are not going to be able to close them. JavaScript will get a permission denied error.

    I posted how to close multiple windows on my blog awhile back: http://radio.javaranch.com/pascarell...152877000.html

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

  • #3
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well your script works better than mine. The only question I have is it possible to either A. Open them all in the same window? B. Is it possible to add a delay to the windows opening say 5 seconds between each other?
    Last edited by mb116; 01-12-2007 at 09:59 PM.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Why do I have this feeling that you are doing this to annoy people? What is the point of the script? You do realize popup blockers will likely block the windows.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Haha, no its not to annoy people, I promise. It's actually for myself. I am making to script to save myself some time. By opening a page a set number of times and then another page just once. If I wanted to annoy people I wouldn't want them to close themselves.. lol.

    Can you offer me any advice?
    Last edited by mb116; 01-12-2007 at 10:50 PM.


  •  

    Posting Permissions

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