Log in

View Full Version : Open a popup and close it again from parent (opener) window



Beverleyh
07-31-2008, 06:25 AM
Hi,

I was wondering... is it possible to open a popup and then close it again from a button on the parent/opener window?

I can open a popup and close it via a button in the popup itself but I cant find a way of closing it from the parent.

If someone knows how, can you post an example please?

Thanks

Beverley

Beverleyh
07-31-2008, 07:13 AM
Ignore me - I got it


<head>

<script language="javascript" type="text/javascript">
<!--
var newwindow = '';
function PopUpWin(url) {
newwindow=window.open(url,'popupname','width=250,height=250,left=100,top=100,resizable=no');
}

function ClosePopUpWin(){
newwindow.close();
}
// -->
</script>

</head>



<body>

<form>
<input type=button onClick="return PopUpWin('popup.html');" value="Open">
<input type=button onClick="ClosePopUpWin();" value="Close">
</form>

</body>


Then obviously you need the "popup.html" page that will open in the popup window.