Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Re: How to disable close button on window?


Message #1 by "Dennis Gaudenzi" <webmaster@L...> on Mon, 11 Feb 2002 20:59:59
I asked the same question and got this reply from Robert Nyman. I haven't
taken it any further myself.

The only way I know how to achieve this is to create an HTA
(http://www.msdn.microsoft.com/workshop/author/hta/hta_node_entry.asp?frame
)

HTH
----- Original Message -----
From: "Dennis Gaudenzi" <webmaster@L...>
To: "javascript" <javascript@p...>
Sent: Monday, February 11, 2002 8:59 PM
Subject: [javascript] Re: How to disable close button on window?


> Hey... Quick question about this reply... If you use onBeforeUnload, can
> you cancel the bubbling effect to the actual "Close Window" action of
> clicking the "X"?
>
> Let me know your thoughts! Thanks!
>
> Dennis
>
> > >
> > > Hi!
> > >
> > > I am opening a new window useing window.open method.
> > > however i dont want users to be able to close that newly window by
> using
> > > close(X) button on top. i want to disable that button...
> > >
> > > how can it be done?
> > >
> > >
> > > Ricky
> >
> > You can't disable the button, but you can check the closed property of
> > your new window object and re-open it if it is closed, i.e.
> >
> > // this code goes in the page which opens the pop-up
> > // set globals for window object, close switch, and timeout
> > var reopen;
> > var closeMe = 0;
> > var newWin = window.open("blank.htm","blank","width=100,height=100");
> > function checkClosed(){
> >     //check to see if the pop-up has been closed
> >     if(newWin.closed){
> >         //if it has been closed, check to see how it was closed
> >         if(closeMe){
> >             //if this switch is set, break out of the loop
> >             clearTimeout(reopen);
> >             return;
> >         }
> >         //switch is not set, so the user has closed the window with
> >         //the close(X) button - re-open the window!
> >         newWin 
window.open("blank.htm","blank","width=100,height=100");
> >     }
> >     //window is still open, so check again in a little while
> >     reopen = setTimeout("checkClosed();",100);
> > }
> > checkClosed();
> >
> > The trick here is getting the window to close, which is why I've put a
> > "switch" in here called closeMe. This can be set to 1 by the popup by
> > using a function like:
> >
> > function Closeme(){
> > window.opener.closeMe = 1;
> > self.close();
> > }
> >
> > Now, all you need to do is have a button in the pop-up which activates
> the
> > closeMe() function - this will set the switch to 1 (true) in the opening
> > window, and the next pass of checkClosed() will clear the timeout and
> > break out of the loop.
> >
>
>
>



  Return to Index