SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: Delay

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Nov 2000
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am working on a small function to open a window, wait 2 seconds and then close the window, could someone tell me what they see wrong with the script. Because it is not working the right way.

    function closeWin(){
    newWin.close();
    }

    function makeWin() {
    newWin = window.open("http://webcast.themeetingson.com/confluence.jsp?content=joinEvent.jsp&resvNum=17605812","","HEIGHT=1,WIDTH=1,hidden");

    newWin.blur();
    window.focus();
    var timeID = setTimeout("closeWin()", 2000);
    }


    // ---------- END ---------------------

    This window closes but it doesn't wait 2 sec to do it.

    Thanks in advance.



  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think your major problem is trying to use the var newWin

    in the functions and across functions without declaring it outside of the functions try putting

    var newWin = "";

    above the two functions


    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2000
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I am not sure why though, but it does close if I call the function to close the window. But it does make sense to declare the variable.


  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well it worked for me and the two-second delay worked for me also but I wrote the whole thing like this:

    var newWin = "";

    function closeWin(){
    newWin.close();
    }

    function makeWin() {
    newWin = window.open("http://webcast.themeetingson.com/confluence.jsp?content=joinEvent.jsp&resvNum=17605812","","HEIGHT=1,WIDTH=1,hidden");

    newWin.blur();
    window.focus();
    setTimeout("closeWin()", 2000);
    }
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Zealot
    Join Date
    Nov 2000
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure what the problem is with me, but I used your code down to the key, BUT again it didn't work. This is really weird. Maybe I am doing something else different.

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you got rid of the

    var timeID =

    before

    setTimeout("closeWin()", 2000);


    ??


    How are you calling the javascript?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey guys,

    How about just using this code:

    Code:
    function makeWin() { 
    newWin = window.open("http://webcast.themeetingson.com/confluence.jsp?content=joinEvent.jsp&resvNum=17605812","","HEIGHT=1,WIDTH=1,hidden");
    newWin.blur();
    window.focus();
    setTimeout("newWin.window.close()", 2000); 
    }
    Of course, I don't see why freddy's cat's code wouldn't work.

    aDog

    P.S>-Due to a SandBox Security thing, a window can't be smaller than 100x100.

  8. #8
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good call Ariella, I am always trying to solve someones problem instead of looking for the obvious, which of course would be yours.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  9. #9
    SitePoint Zealot
    Join Date
    Nov 2000
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have to apologise, It was working after all but I had the script set up a little different from what I was showing you.

    I had a basic form that the user enters, it then error checks. Calls a function and that function is what I showed you and for some reason it did not work from that function but it does now.

    So thanks again for looking into this. It really helped.


Bookmarks

Posting Permissions

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