Click to See Complete Forum and Search --> : popup close wrong window ?


andrew1234
06-30-2003, 11:45 AM
hi below is the script

there is a button that "onmouseover" a popup loads.

"onmouseout" the popup is suposed to close but right now it closes the main window and not the popup

how do i make it close the popup

thanks

Andrew





<html>
<head>
<title>Untitled Document</title>


<script type="text/javascript">

function fred(URL)
{
window.open(URL,"","height=260,width=380,resizable=0, left=100, top=100" );
}
function mark(URL)
{
window.close(URL);
}

</script>
</head>
<a onmouseover="javascript:fred('fred.htm')" onmouseout="javascript:mark('fred.htm')" >
<img src="hary.gif" name="Image31" width="142" height="55" border="0" id="Image31"></a>
<body>

</body>
</html>

Khalid Ali
06-30-2003, 11:55 AM
you need to get a reference to the new window and then close that.the way u are using its targetting the main window.Use the code below

<script type="text/javascript">
var popupWin;
function fred(URL)
{
window.open(URL,"","height=260,width=380,resizable=0, left=100, top=100" );
}
function mark(URL)
{
if(popupWin!=null && !popupWin.closed){
popupWin.close();
}
}

</script>