siri Posted December 20, 2007 Share Posted December 20, 2007 I am using the following code but somehow the win variable is not getting reset to null.I don't want to open new window when a window is already opened.<html><head><script type ="text/javascript"> var win;function demo(){if(win==null){ win = window.open("","popup","toolbar=no,menubar=yes,statusbar=yes,width=180,height=280,left=300,top=180");msg = "<html><title>Demo</title>";msg +="<body>";msg +="<hr size='1'>";msg += "<input type='button' value='submit' onclick='self.opener.document.forms[0].t1.value=this.value;self.close()'>";win.document.write(msg); } }</script></head><body><form><input type="text" name="t1"><input type="button" value="Click Me" onclick="demo()"></form></body></html> Link to comment Share on other sites More sharing options...
aspnetguy Posted December 20, 2007 Share Posted December 20, 2007 the following works <html><head><script type ="text/javascript">var win;window.isWindowOpen = false;function demo() { if(!window.isWindowOpen) { if(win = window.open("","popup","toolbar=no,menubar=yes,statusbar=yes,width=180,height=280,left=300,top=180")) { window.isWindowOpen = true; } msg = "<html><title>Demo</title>"; msg +='<body>'; msg +="<hr size='1'>"; msg += "<input type='button' value='submit' " + "onclick='self.opener.document.forms[0].t1.value=this.value;self.opener.window.isWindowOpen=false;self.close()'>"; win.document.write(msg); } }</script></head><body><form><input type="text" name="t1"><input type="button" value="Click Me" onclick="demo()"></form></body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.