Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Need help determining when remote window closes.
- From: glenn_lanier at netzero.net (Glenn E. Lanier, II)
- Subject: [Javascript] Need help determining when remote window closes.
- Date: Tue Jun 21 10:34:55 2005
Hi, I want to open a new browser window, let the user use that window for several minutes, and when they close the window, I'd like to change the page displayed in the original window. According to numerous articles found Googling, this should work, but on my WinXP system, using Firefox and IE, I get nothing (when allowing pop-ups, if pop-ups are disabled, IE reports the window is closed, Firefox gives a JS error on checking the window handle). No JS errors, no notifications, nothing. Any pointers would be appreciated. File 1 contains the code I'm using to open the window, to check for closure, and a form textarea that I update with the time (mostly so I know my timer is firing properly). ---- FILE 1 BEG ---- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Opener Page</title> </head> <body> <h1>Opener</h1> <form name="frmOutput"> <textarea name="txtOutput" rows=5 cols=80></textarea> </form> <p><a href="javascriptstopChecking();">Stop Checking</A></p> <script language="Javascript"> log("Start", true); var remoteWin = window.open("Remote.html", "remote", 'toolbar=no, location=no, directories=no, status=yes, menubar=no, width=795, height=500, resizable=yes, scrollbars=yes, screenx=0, screeny=0, top=0, left=0'); var timer = null; function checkClosed() { log("Checking...", false); timer = setTimeout("checkClosed()", 5000); // Check every 5 seconds. if (!remoteWin) { alert("Window no longer exists"); stopChecking(); } else if (remoteWin.Closed) { alert("Window Closed"); stopChecking(); } } timer = setTimeout("checkClosed()", 5000); // Check every 5 seconds. function stopChecking() { log("Stop checking.", false); clearTimeout(timer); } function log(sText, bClearContents) { var d = new Date(); var s = d.getFullYear() + "." + d.getMonth() + "." + d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + " " + sText + "\r\n"; if (bClearContents) { document.frmOutput.txtOutput.value = s; } else { document.frmOutput.txtOutput.value = s + document.frmOutput.txtOutput.value; } } </script> </body> </html> ---- FILE 1 END ---- File 2 contains some filler text. I can not change the source of this window (when live). ---- FILE 2 BEG (remote.html) ---- <html><head><title>Remote</title></head><body><h1>Remote Window</h1><p>Closing me should alert the original window or allow the original window to know when I <a href="javascriptwindow.close();">close</a>.</p></body></html> ---- FILE 2 END (remote.html) ---- Thanks for any help. Glenn _____ Glenn E. Lanier II * Email: <mailto:glenn_lanier@xxxxxxxxxxx> glenn_lanier@xxxxxxxxxxx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.LaTech.edu/pipermail/javascript/attachments/20050621/15ebb340/attachment.html
- Follow-Ups:
- [Javascript] Need help determining when remote window closes.
- From: Shawn Milo
- [Javascript] Need help determining when remote window closes.
- From: Andrew Clover
- [Javascript] Need help determining when remote window closes.
- Prev by Date: [Javascript] Javascript design
- Next by Date: [Javascript] Need help determining when remote window closes.
- Previous by thread: [Javascript] Scroll bar
- Next by thread: [Javascript] Need help determining when remote window closes.
- Index(es):