Click to See Complete Forum and Search --> : Relationship between child and parent window


jovialjonny
06-04-2003, 09:29 AM
Hey,
I'm using a parent window to open a child window at the click of a button like so:
window.open("multiviewer.html", "mv");

The problem is I only want to open the window once, I have tried a few ways around this but no matter what I do the window keeps reloading on each button click. Right now the code looks like this:
var viewer = false;
var url;
function callViewer(theUrl)
{ if(viewer ==false )
{ window.open("multiviewer.html", "mv");
viewer =true;
}
url = theUrl)
}

(callViewer is the onClick method of the button)
Any advice would be great please

Khalid Ali
06-04-2003, 09:34 AM
It should work..anyways try the following condition

if(!viewer)

pyro
06-04-2003, 09:35 AM
This worked fine for me:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language="JavaScript" type="text/JavaScript">
var viewer = false;
function callViewer(url) {
if (viewer == false) {
window.open(url, "mv");
viewer = true;
}
}
</script>

</head>

<body>
<a href="#" onclick="callViewer('http://www.w3c.org')">open</a>
<a href="#" onclick="callViewer('http://www.mozilla.org')">open2</a>
</body>
</html>