Windows Detection
Posted: Thu Jan 01, 2004 5:27 pm
Is there a way in Javascript to detect if a certain popup window is open already?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
mynewwindow=window.open('','','toolbar=no,scrollbars=no,width=300,height=150')
if (newWindow.closed) {
// it is closed
} else {
// it is not closed
}Code: Select all
<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
newwindow=window.open(href, windowname, 'width=400,height=100,scrollbars=no,toolbar=no,status=no,resizable=no');
return false;
}
//-->
</SCRIPT>
<SCRIPT TYPE="text/javascript">
if (newwindow.closed) {
} else {
<BODY onLoad="popup('http://eckclan.sytes.net/cgi-bin/musicphp5.php', 'eckmusic')">
}
</script>Code: Select all
<html>
<head>
<title>JavaScript Window Close Example </title>
</head>
<SCRIPT language="JavaScript1.2">
function popuponclick()
{
my_window = window.open("",
"mywindow","status=1,width=350,height=150");
my_window.document.write('<H1>The Popup Window</H1>');
}
function closepopup()
{
if(false == my_window.closed)
{
my_window.close ();
}
else
{
alert('Window already closed!');
}
}
</SCRIPT>
<body>
<P>
<A href="javascript: popuponclick()">Open Popup Window</A>
</P>
<P>
<A href="javascript: closepopup()">Close the Popup Window</A>
</P>
</body>
</html>Code: Select all
<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=400,height=100,scrollbars=no,toolbar=no,status=no,resizable=no');
return false;
}
//-->
</SCRIPT>
<BODY onLoad="popup('http://eckclan.sytes.net/cgi-bin/musicphp4.php', 'eckmusic')">Code: Select all
<SCRIPT TYPE="text/javascript">
function closepopup()
{
if(false == eckmusic.closed)
{
eckmusic.close ();
}
}
</script>Code: Select all
<script language="JavaScript" type="text/javascript">
<!--
//
var image1 = 10;
var image2 = 10;
function image1Loaded()
{
image1 = 11;
if( (image1==11)&&(image2==12) )
{
read2go();
}
}
function image2Loaded()
{
image2 = 12;
if( (image1==11)&&(image2==12) )
{
read2go();
}
}
function read2go()
{
if( (image1==11)&&(image2==12) )
{
for(var i=0; i<100000; i++)
{
var today = new Date();
var secs = today.getSeconds();
if( (secs % 5)==0 )
{
movePointer();
break;
}
}
}
}
//...
// end hiding contents -->
</script>