Return to Help Center

Welcome to the Bravenet Help Forums. Here you can chat and meet other Bravenet Members. Please do not post advertisements.

Coding Discussions
This Forum is Locked
Author
Comment
Close Window Button

I'm looking for a code that works in Firefox. The code below works fine in IE. A web search turns up a lot of posts saying it can't be done but they are mostly very old (years). I'm hoping something new has come along that works.

Thanks

< input value="Close Window" ="window.close()" type="button" >

Re: Close Window Button

Firefox, and most browsers, place restrictions on window closing. I know that Firefox will only let a script close a window that it has control of, which means that the script that tries to close it has to be the one that opened it.

If you want a workaround I'm sure there's plenty out there, but I would try to get an intermediary page that opens the page you're working with, and then you can pass a trigger back so that you can close it again (if that makes sense).

-Scut

Re: Close Window Button

Thanks. I believe the page is set up like what you are saying, my website will have a page with a lyrics index. Click on individual titles and a page opens in a separate window with just lyrics of one song. I want to close this second page with the close button. I guess I just don't know enough to figure out how to do this.

Re: Close Window Button

Have a look at this page http://www.webreference.com/js/tutorial1/opener.html. You should be able to create a function on the page that opens the window. In that function do the lyricWindowName.close() code and you should be able to call that function from the lyrics window using the window.opener code.

Re: Close Window Button

Oh great! Thanks so much. Nice tutorial page.

Re: Close Window Button

It was just a google search, but I'm glad you've got it sorted.