homepage Welcome to WebmasterWorld Guest from 54.196.69.189
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
problem with window.close
not working in mozilla
matt_poole




msg:1489544
 10:46 am on Jul 30, 2003 (gmt 0)

Hi guys,

I've posted on this problem before and got some help on the matter and I went away to try the suggestions, but it still doesnt work. Here's the thing...

I've got a image onto which I attach a the close(); method to close the window.

<a href="javascript:window.close();" ><img src="images/close.gif" width="21" height="20" border="0" alt="Close Window"/></a>

the problme is no matter how I arrange things it just wont close the window in mozilla.

I've tried

window.close();
this.window.close();
self.close();

Both in the anchor and as a onclick handler on the image itself now all of these work in netscape 4+ and IE 4+, just not in mozilla.

The annoying thing is that its works else where in the site in a pop up window. Its really got me stumped!

has any one got any suggestions?

 

HocusPocus




msg:1489545
 12:36 pm on Jul 30, 2003 (gmt 0)

Haven't come across this before. Here's a few more to try!

top.close();
close();

korkus2000




msg:1489546
 1:32 pm on Jul 30, 2003 (gmt 0)

So is this a pop up you are trying to close or the main window they surfed in on?

Sinner_G




msg:1489547
 1:39 pm on Jul 30, 2003 (gmt 0)

Which Mozilla version/OS are you using? The method works fine for me with Moz 1.3.1 and Win2K.

matt_poole




msg:1489548
 1:42 pm on Jul 30, 2003 (gmt 0)

cheers for the sugestions HocusPocus...(didnt work!)

korcus: I think I know where you might be going with your question... It is in the first page you come to. I guess you might wonder why Im bothering when the user can just close the page in the normal way - it just that its possible to navigate to the main page from fullscreen mode ater in in the site :. no close button. I know I could work around this, but I'm stubborn. :)

so was I right is that what you gonna say?

matt_poole




msg:1489549
 1:44 pm on Jul 30, 2003 (gmt 0)

Im using mozilla 1.3.1 and win2k too. I probably should worry about it and get on with the rest of the site, but ARRRRGH!

Sinner_G




msg:1489550
 1:53 pm on Jul 30, 2003 (gmt 0)

Hmm, just to be sure, do you get an alert telling you the window wants to close in IE?

matt_poole




msg:1489551
 1:54 pm on Jul 30, 2003 (gmt 0)

yeah I get that. (but not in fullscreen mode strangley)

Sinner_G




msg:1489552
 2:08 pm on Jul 30, 2003 (gmt 0)

Well, the problem seems not to be Mozilla but the other browers (particularly Netscape, as you don't even get the alert). Normally you should not be able to close the primary window in any browser.

Why the different browsers show different behaviours is a mistery to me, though. Normal would be as IE in non full-screen mode.

korkus2000




msg:1489553
 2:09 pm on Jul 30, 2003 (gmt 0)

I will try and hunt up some docs. When javascript was being created closing the main window wasn't allowed and was a big controversy. I wonder if mozilla will not allow this. I will do some checking.

matt_poole




msg:1489554
 2:39 pm on Jul 30, 2003 (gmt 0)

Thanks guys for your help, I appreciate you time! :)

korkus2000




msg:1489555
 3:31 pm on Jul 30, 2003 (gmt 0)

I am not sure why the other browsers are letting you close the original window. You should not be able to do this. Have you tried it in Opera. I am guessing you will get the same problem. The only thing I can tell you is to open the site in a window you "own". This is not a great solution because it is bad for search engines.

matt_poole




msg:1489556
 8:46 pm on Jul 30, 2003 (gmt 0)

Im not sure what you mean by "own", but to clarify things the button is on the main page of my site this page has a iframe on it but the button is not 'inside' the frame.

does this make a difference?

The site is part of a larger intranet site so Im not too worried about search engines.

drbrain




msg:1489557
 8:55 pm on Jul 30, 2003 (gmt 0)

Did you check the Javascript console?

If I type 'javascript:window.close()' into the URLbar, I get 'Scripts may not close windows that were not opened by script.' in the JS console. (Yes, Mozilla actually has a useful JS console *gasp*, along with a JS debugger, no, really.)

matt_poole




msg:1489558
 9:14 am on Jul 31, 2003 (gmt 0)

Sarcy... I knew there was a reason to use Mozilla :P

Well that would make sense then. I'll just have to loose the close button in mozilla. Thanks guys for the help.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved