Jump to content

window.close not working


k_romych

Recommended Posts

I open new window with the next script:function mwindow1(){mwind1 = window.open('uploadw.htm','mywindow','width=400,height=200');}and trying to close it from parent window with this script:<script type="text/javascript"> if (mwind1 && mwind1.open && !mwind1.closed) mwind1.close(); </script>when i do it in mozzila it just doesnt closewhen i do it in IE i get an error: mwind1 is not definedany suggestions?thanks

Link to comment
Share on other sites

That's because mwind1 is a local variable to the function mwindow1().Put it like this instead:

var mwind1;function mwindow1(){mwind1 = window.open('uploadw.htm','mywindow','width=400,height=200');}

Link to comment
Share on other sites

You should change this:

if (mwind1 && mwind1.open && !mwind1.closed) mwind1.close();

For this:

if (mwind1 && !mwind1.closed) mwind1.close();

There is no open property for the Window object.

Link to comment
Share on other sites

Well, just for testing, write mwind1.close(); right there and forget the if statement to see what it does.Is this page online somewhere?I could quickly find the problem with Firefox's error console.And if not, maybe you're running the script in the wrong place, so it would help me to know where these scripts are located.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...