Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > window.close() in IE

Reply
Thread Tools

window.close() in IE

 
 
David
Guest
Posts: n/a
 
      08-19-2005
Hey all,

I have a script that dynamically sets the window.onunload of the current
window to point to a function that, when run, will close another dependent
window (if it's opened). This works fine when I am hitting refresh on the
browser, as the onunload event for the window fires and closes the other
dependent window. However, if I close the window, it is still firing the
onunload event, but I am getting a javascript "Permission denied" error (and
since I have script errors always showing, I see it before the window
closes). Sometimes it closes the dependent window, sometimes it doesn't.
Any ideas what might be going on here or a workaround? The same code works
fine in Firefox and I have not tested it in anything else. The IE version
is 6 (with SP2).

Thanks,

David


 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      08-19-2005
David wrote:
> if I close the window, it is still firing the
> onunload event, but I am getting a javascript "Permission denied" error (and
> since I have script errors always showing, I see it before the window
> closes). Sometimes it closes the dependent window, sometimes it doesn't.
> Any ideas what might be going on here or a workaround? The same code works
> fine in Firefox and I have not tested it in anything else. The IE version
> is 6 (with SP2).


may be with a timer ?

<body onunload="setTimeout('popup.close()',10);">

or

<body onunload="setTimeout('popup.close()',0);">

or

<body onunload="popup.close();
setTimeout('alert(\'I did close popup\')',100);">


--
Stephane Moriaux et son [moins] vieux Mac
 
Reply With Quote
 
 
 
 
David
Guest
Posts: n/a
 
      08-22-2005
ASM Wrote:
>
> may be with a timer ?
>
> <body onunload="setTimeout('popup.close()',10);">
>
> or
>
> <body onunload="setTimeout('popup.close()',0);">
>
> or
>
> <body onunload="popup.close();
> setTimeout('alert(\'I did close popup\')',100);">
>

Yea, I thought of the same thing and tried it, but if I put it in a
setTimeout the code never gets executed. I put an alert in and never saw
it. I tried 0, 10 and 100 for the times. I know that the line of code
where it sets the timeout is getting run because I put an alert after it and
I get that alert. This is really weird.

Anyways, after looking into it more, that's not actually where the problem
is. The problem is in the onunload code for the popup window. The popup
has an onunload that calls this function.

function closeCart()
{
if (window.opener)
{ window.opener.blCartIsOpen=false
window.opener.currCartSel=null
}
}

Now, I realized I had to add the window.opener part because I was getting an
error in Firefox as well that was saying that window.opener had no
properties. However, that condition solved the problem there. In IE, I am
still getting the Permission denied error. Somehow, it is getting through
the condition (meaning that window.opener still exists) but it is freaking
out when trying to set those variables. Any ideas what might be going on
here? I figure that if all else fails I can have the main window set a flag
that will keep this code from running when it closes it.

David


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57