Results 1 to 2 of 2

Thread: Window.alert script problem/question

  1. #1
    Join Date
    Aug 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Window.alert script problem/question

    I would like a script that prompts an alert after visitors click to view a large video file (the "Play PDM Montage Clip" link) at:

    www.pdmdigital.com/slideshows.htm

    The script that I wrote looks like this:

    function loadtime()
    {window.alert("Please be patient as this clip is a large file. Thanks, PDM")
    setTimeout("loadtime()", 1500)
    }

    There are a few problems. First, for some reason the function is called when you click on the "Photo Montages/Slideshows" link from any of the four pages, not just the 'Play' link where the function is called from the onClick event handler.

    Second, it keeps popping up repeatedly. The reason I attempted to put in a timeout is so that Windows Media Player (or whatever media player) would pop up first and begin buffering, THEN the alert would pop up and say please be patient. Any and all help is truly appreciated, thanks much for reading this, theMind-

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Your first problem is an illusion, as the function must still be running, try it without ever clicking on the link for 'Play' in the first place, no problem. The second problem is due to a misunderstanding on your part (I think) of what setTimeout means. It means, wait for (in this case) 1.5 seconds and do whatever is quoted in the first part of the parenthesis. So, the way you have it, every time the script runs to its end, it sets a call to run itself again in 1.5 seconds. This is exactly what is happening. Fortunately, while the alert is showing, script functions are paused, or it would be very hard to break out of the loop that you've created without ending the browser program using taskmanager. Just get rid of the setTimeout and it should be fine.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •