Popup onunload issue with IE.

D

Donius

So i'm doing some popups. I wanted to make sure that if one closed,
they all close. IE (win) is giving me some troubles. It has several
issues.

1. It won't display page changes until i give the window the focus
manually. So if after the page loads, i change some things, those
changes don't display until i select the window.
2. It ignores my onunload function. It doesn't call it. This makes me
sad. The onunload is key to what the app is trying to do.

I hacked down the code so that it's the barebones ((the problems are
still there in this hacked down version)) of what i'm trying to do...so
my apologies if there are absent variables or the like. Anyone have
any ideas?

I pop them up like this:

/* ---
Code:
 -------------------- */

var windows = Array();
// The inital page guts
var page = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"\n
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html>\n\t<head>\n\t\t<title>Popped
Up Tab</title>\n\t</head>\n\t<body
onLoad="window.opener.drawPopup(whichWin);">\n\t\t<div
id="bobby">INITIAL DIV</div>\t</body>\n</html>';

// Popup the windows
for(var i = 0; i<someval; i++){
windows[i] = window.open('', 'tabpop'+i, '');
windows[i].document.write(page.replace(/whichWin/, i));
windows[i].document.close();
}

// Draws out the popup windows.
function drawPopup(whichWin){
// Get some vars
windoc[whichWin] = windows[whichWin].document;
winbody[whichWin] = windoc[whichWin].body;
// Assign the onunload, change the page ((simplified))
windows[whichWin].onunload =
windows[whichWin].opener.closePopups;
winbody[whichWin].innerHTML =
"<span >"+windows[whichWin].onunload+"</span>";
// Give focus.
windows[whichWin].focus();
}

function closePopups() {
if(confirm("Close all open tab popups?")){
// first make sure the windows have no
// unload functions...like this one
for(var i = 0; i < windows.length; i++){
windows[i].onunload = '';
}
// then close all the windows.
for(var i = 0; i < windows.length; i++){
windows[i].close();
} 	} 	}

/* ---
------------------- */

-Brendan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top