Join 3,557 readers in helping fund MetaFilter (Hide)


auto close pop up window
June 23, 2006 10:36 AM   Subscribe

How do I alter this piece of code to make the pop up window close automatically after exactly 37 seconds?

Here's the piece of code with { } substitued for <>:

{script language="javascript"}
timer=setTimeout("window.open('video_popup.html',','width=550,height=400')",5000)
{/script}
posted by wsg to Computers & Internet (16 answers total)
 
timer=setTimeout("window.open('video_popup.html',','width=550,height=400')",37000)
posted by Capn at 10:38 AM on June 23, 2006


Capn, your code makes the pop up window wait 37 seconds before it opens. I want it to open immediately and close after 37 secs.
posted by wsg at 11:12 AM on June 23, 2006


If the page you're popping up is one that you control (and can add code to), you should be able to do something similar to what you have there. Instead of using window.open() on a time, there's a window.close() method that closes a window (I'm not sure if it's still useful, but it used to be that you could only close JS-opened windows with JS, and you couldn't close user-opened windows like the main browser window (at least, not without a prompt of some kind)).
posted by Godbert at 11:18 AM on June 23, 2006


So, you would have something like this in a script block in the video_popup.html page:
timer=setTimeout("window.close()",37000)

I'm not sure if there's a way to do it from the page that opened it, if that's what you're asking.
posted by Godbert at 11:23 AM on June 23, 2006


Thanks, Godbert. That did it.
posted by wsg at 11:51 AM on June 23, 2006


Wow. Im curious about the "37 seconds" value. Where did that come from?
posted by Brainy at 1:09 PM on June 23, 2006


Brainy,

The pop up contains a short (37 seconds) flash video of a live band. Whomever designed the pop up page originally set the video to loop, which is really annoying. I don't have the fla. file, just the swf, so I can't edit the flash file to not loop. Now, the window closes as soon as the clip has played once, before it has a chance to loop again. I would post a link, but I'm afraid the bandwidth strain on the server would be prohibitive.
posted by wsg at 2:04 PM on June 23, 2006


The video is exactly 37 long and you're over-optimistically betting there are no network issues that will

      buffering... buffering... buffering...

cause the video to actually take longer to run?
posted by orthogonality at 2:05 PM on June 23, 2006


You have a point orthogonality. I will have to test it on some other machines. What do you recommend? Obviously, I am a novice programmer.
posted by wsg at 2:07 PM on June 23, 2006


I'm kinda screwed without having access to the fla. file.
posted by wsg at 2:36 PM on June 23, 2006


Been a long time since I fiddled with javascript like that, but would calling the timer from onLoad() work to beat the "buffering..." issue? e.g.
<script>
function CloseWindow() {
  timer=setTimeout("window.close()",37000);
  return true;
}
</script>
<body onLoad(CloseWindow())>
(On second thoughts: probably not, because the video is an embedded object...)
posted by Pinback at 2:59 PM on June 23, 2006


I bet if you'd asked "how can I deconstruct and edit a SWF file for which I don't have the original FLA?" you'd have got your looping problem sorted already.
posted by AmbroseChapel at 5:35 PM on June 23, 2006


Have you tried putting {PARAM NAME="LOOP" VALUE="false"} within the OBJECT statement and LOOP="false" into the EMBED tag? This won't help if the flash file was built with a specific gotoAndPlay(1) command but should help override the default looping.
posted by blag at 6:36 PM on June 23, 2006


AmbroseChapel, in my ignorance, I didn't realize that was an option. How can I deconstruct and edit an SWF file for which I don't have the original fla.?
posted by wsg at 11:45 PM on June 23, 2006


You'll just have to wait a week and ask again!

No seriously. I haven't done it myself but I've sat next to someone who did it all the time, using, I think, SWFDecompiler.
posted by AmbroseChapel at 2:56 AM on June 24, 2006


blag, that worked. Thanks. Y'all are good! (But, I knew that already.)
posted by wsg at 9:44 AM on June 24, 2006


« Older What should I do with an old T...   |  A couple months ago I download... Newer »
This thread is closed to new comments.