Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pop-up that closes browser and self

Status
Not open for further replies.

StephanieCC

Technical User
Aug 28, 2001
48
US
I've created a pop-up with yes/no buttons that should close itself when yes is clicked, leaving the homepage on the screen--that works--what I'd like is for the no button to close the pop-up and the browser--on the pop-up, for NO I am using onclick window.close (I've also tried browser.close) and on the homepage which is where the pop-up script is, I have set the pop-up window to dependent--I thought dependent and close window worked together to do what I'd like but . . .

 
It is a security measure to prevent a script from closing a browser window. The only thing that is supposesed to be closable are windows that were opened using javascript.

However, there is an IE only workaround (note I got this info from other people and sources):

Put this code in the browser page:
<OBJECT id=closes type=&quot;application/x-oleobject&quot; classid=&quot;clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11&quot;>
<PARAM NAME=&quot;Command&quot; VALUE=&quot;Close&quot;>
</OBJECT>
<script language=&quot;JavaScript1.2&quot;>
<!--
function closeWin() {
if (typeof window.ActiveXObject != 'undefined') {
try {
closes.Click();
}
catch (error) {
alert(error);
}
}
else {
//this means the browser does not support the ActiveX object and you cannot close the browser window
//put whatever you want here
}
}
//-->
</script>

And put this code in the pop-up window (the way I understand it, you want the pop-up to close everything).

if(window.opener && !window.opener.closed) { opener.closewin(); }
//now put your code to close the pop-up
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top