Jump to content

Window .close();


S@m

Recommended Posts

..search is not working at the moment, so please direct me if this has been covered already.I am working on closing a window (non-popup) with a text link.

window.close();

But, as you know unless that window was opened w/ window.open(), you will get an alert message along the lines of "something is trying to close the window..."I did some looking around. Found this:

window.opener='x';window.close();

Now, the explanation was that it (the browser) checks the value of "opener" if it is equal to nothing, then you get the error. So, if it equals something, the window will close.That I understand. Makes sense.My js skills are pretty "low" I can read/understand but when it comes to debugging...not so good.IE this script works fine. No problems.But Firefox, I get this:uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: java script:window.opener='x';window.close(); :: <TOP_LEVEL> :: line 1" data: no]I don't understand what it can't convert.I looked around for answers, but didn't come up with much.I have also tried the technique on interwebby:

<script language="javascript" type="text/javascript">function closeWindow() {window.open('','_parent','');window.close();}</script>

But again, fine in IE...not in FF.It seems to me that if I can force opener to equal something, then I should be good right?Any suggestions?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...