Jump to content

Open One Instance of POPUP WIndow


siri

Recommended Posts

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

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

Archived

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

×
×
  • Create New...