473,396 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

window.close() in IE

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
Aug 19 '05 #1
2 4830
ASM
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
Aug 19 '05 #2
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
Aug 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Nigel Mercier ® | last post by:
I'm just starting to learn JavaScript, so far I like it! I want to add some JS to my Ebay listings, to manually open a pop-up window. It works OK, but the JS gets rejected by Ebay. If I can't...
3
by: Steve | last post by:
Hi, I have a nice little script that works well displaying images on my website. It's a script where if you clik a thumbnail image a pop up window opens that contains a larger version of the same...
9
by: Graham | last post by:
What I currently have is a page that opens another browser at 800x600, once that is loaded I would like to close the orginal page down while keeping the page that it has just opened open (To make...
4
by: GrantS | last post by:
I am having a problem closing a popup window opened modally. When I try to close the window (when the user hits save button and the data has been processed), the Popup window opens as a full screen...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
5
by: lindanr | last post by:
In ASP.NET 2005 I have an onblur="window.close()" javascript event in the <body> tag. When I click on the window's scrollbar, the window closes. The same code works fine in ASP.NET 2003. Any...
9
by: Stan B | last post by:
I create a popup window by calling window.showModalDialog Popup window has Ok button with this code attached: === string Script = "<script language=JavaScript>" + "{" + "window.close();" +...
7
by: Toccoa | last post by:
After considerable googling - I mean searching with Google(r) - I could not find javascript on a button or <a href=... to close a window in the latest versions of IE and FireFox. There seemed...
2
by: kurt sune | last post by:
Hello, I have a weird problem, I hope someone can explain this for me. I have a webpage using masterpage. In it I create a popup window using this code: Dim js As String = "<script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.