Welcome to WebmasterWorld Guest from 54.196.232.162

Forum Moderators: open

Message Too Old, No Replies

problem with window.close

not working in mozilla

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

New User

10+ Year Member

joined:June 11, 2003
posts:13
votes: 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?

12:36 pm on July 30, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 27, 2002
posts:125
votes: 0


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

top.close();
close();

1:32 pm on July 30, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 20, 2002
posts:3732
votes: 0


So is this a pop up you are trying to close or the main window they surfed in on?
1:39 pm on July 30, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 27, 2002
posts:959
votes: 0


Which Mozilla version/OS are you using? The method works fine for me with Moz 1.3.1 and Win2K.
1:42 pm on July 30, 2003 (gmt 0)

New User

10+ Year Member

joined:June 11, 2003
posts:13
votes: 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?

1:44 pm on July 30, 2003 (gmt 0)

New User

10+ Year Member

joined:June 11, 2003
posts:13
votes: 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!
1:53 pm on July 30, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 27, 2002
posts:959
votes: 0


Hmm, just to be sure, do you get an alert telling you the window wants to close in IE?
1:54 pm on July 30, 2003 (gmt 0)

New User

10+ Year Member

joined:June 11, 2003
posts:13
votes: 0


yeah I get that. (but not in fullscreen mode strangley)
2:08 pm on July 30, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 27, 2002
posts:959
votes: 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.

2:09 pm on July 30, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 20, 2002
posts:3732
votes: 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.
2:39 pm on July 30, 2003 (gmt 0)

New User

10+ Year Member

joined:June 11, 2003
posts:13
votes: 0


Thanks guys for your help, I appreciate you time! :)
3:31 pm on July 30, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 20, 2002
posts:3732
votes: 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.
8:46 pm on July 30, 2003 (gmt 0)

New User

10+ Year Member

joined:June 11, 2003
posts:13
votes: 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.

8:55 pm on July 30, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 18, 2003
posts:827
votes: 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.)

9:14 am on July 31, 2003 (gmt 0)

New User

10+ Year Member

joined:June 11, 2003
posts:13
votes: 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.