k_romych Posted September 14, 2008 Share Posted September 14, 2008 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 More sharing options...
Ingolme Posted September 14, 2008 Share Posted September 14, 2008 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 More sharing options...
k_romych Posted September 14, 2008 Author Share Posted September 14, 2008 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');} still not working, but now IE doesnt give any error Link to comment Share on other sites More sharing options...
Ingolme Posted September 14, 2008 Share Posted September 14, 2008 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 More sharing options...
k_romych Posted September 14, 2008 Author Share Posted September 14, 2008 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. still no luck Link to comment Share on other sites More sharing options...
Ingolme Posted September 14, 2008 Share Posted September 14, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.