Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Prevent window closing

Reply
Thread Tools

Prevent window closing

 
 
danny
Guest
Posts: n/a
 
      12-23-2003

Is there a way I can prevent the browser window from being closed? I'd
like to make sure the browser window only closes programatically (I want
to make sure the user enters data before moving on).

Another possible solution would be to re-open the window when it's
closed.

Any help is appreciated, thanks.
 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      12-23-2003
danny wrote:

> Is there a way I can prevent the browser window from being closed?


No. (Although porn sites with hundreds of blinking banner adverts would love
it if it were possible)

> I'd like to make sure the browser window only closes programatically (I
> want to make sure the user enters data before moving on).


This is the web. You can't force the user to do anything. Make the
application robust enough to survive the user doing the unexpected.

--
David Dorward <http://dorward.me.uk/>
 
Reply With Quote
 
 
 
 
danny
Guest
Posts: n/a
 
      12-23-2003
In article <bsagsp$tg$1$>,
says...
> danny wrote:
>
> > Is there a way I can prevent the browser window from being closed?

>
> No. (Although porn sites with hundreds of blinking banner adverts would love
> it if it were possible)


I bet!

> > I'd like to make sure the browser window only closes programatically (I
> > want to make sure the user enters data before moving on).

>
> This is the web. You can't force the user to do anything.


Actually, It's not for an internet application. I'm building a thin
client application. It's a call center application, and when a contact
is closed, they are supposed to enter data. Problem is, because it's a
browser, they can just click the X mark and close the window, which
leaves the contact waiting for data to move to another state. If I
could pop the window back up and request the data again, that is
acceptable, but I haven't yet figured that out.

> Make the
> application robust enough to survive the user doing the unexpected.


Gee thanks... I thought that's what I *WAS* doing...
 
Reply With Quote
 
@SM
Guest
Posts: n/a
 
      12-23-2003
danny a ecrit :
>
> In article <bsagsp$tg$1$>,
> says...
> > danny wrote:
> >
> > > Is there a way I can prevent the browser window from being closed?

> >
> > No. (Although porn sites with hundreds of blinking banner adverts would love
> > it if it were possible)

>
> I bet!
>
> > > I'd like to make sure the browser window only closes programatically (I
> > > want to make sure the user enters data before moving on).

> >
> > This is the web. You can't force the user to do anything.

>
> Actually, It's not for an internet application. I'm building a thin
> client application. It's a call center application, and when a contact
> is closed, they are supposed to enter data. Problem is, because it's a
> browser, they can just click the X mark and close the window, which
> leaves the contact waiting for data to move to another state. If I
> could pop the window back up and request the data again, that is
> acceptable, but I haven't yet figured that out.


supose your funtion to send your data is
function sendData(){ blah blah ; DataOk=1;}

var DataOk =0;
</script></head>
<body onunload="if(DataOk==0) sendData();"

Would works with IE
 
Reply With Quote
 
danny
Guest
Posts: n/a
 
      12-23-2003
In article <>,
says...
> danny a ecrit :
> >
> > In article <bsagsp$tg$1$>,
> > says...
> > > danny wrote:
> > >
> > > > Is there a way I can prevent the browser window from being closed?
> > >
> > > No. (Although porn sites with hundreds of blinking banner adverts would love
> > > it if it were possible)

> >
> > I bet!
> >
> > > > I'd like to make sure the browser window only closes programatically (I
> > > > want to make sure the user enters data before moving on).
> > >
> > > This is the web. You can't force the user to do anything.

> >
> > Actually, It's not for an internet application. I'm building a thin
> > client application. It's a call center application, and when a contact
> > is closed, they are supposed to enter data. Problem is, because it's a
> > browser, they can just click the X mark and close the window, which
> > leaves the contact waiting for data to move to another state. If I
> > could pop the window back up and request the data again, that is
> > acceptable, but I haven't yet figured that out.

>
> supose your funtion to send your data is
> function sendData(){ blah blah ; DataOk=1;}
>
> var DataOk =0;
> </script></head>
> <body onunload="if(DataOk==0) sendData();"
>
> Would works with IE


Would this prevent the window from unloading? Or would I have to handle
that someplace else?
 
Reply With Quote
 
Eric Bohlman
Guest
Posts: n/a
 
      12-23-2003
danny <> wrote in
news: m:

> Actually, It's not for an internet application. I'm building a thin
> client application. It's a call center application, and when a
> contact is closed, they are supposed to enter data. Problem is,
> because it's a browser, they can just click the X mark and close the
> window, which leaves the contact waiting for data to move to another
> state. If I could pop the window back up and request the data again,
> that is acceptable, but I haven't yet figured that out.


You need to properly handle that on the server end since you also have to
deal with contingencies like the client machine crashing, the client
machine losing power, or a network outage, all of which could result in no
data being entered at a particular state in the application.
 
Reply With Quote
 
danny
Guest
Posts: n/a
 
      12-24-2003
In article <Xns945AB9C7281C7ebohlmanomsdevcom@130.133.1.4>,
says...
> danny <> wrote in
> news: m:
>
> > Actually, It's not for an internet application. I'm building a thin
> > client application. It's a call center application, and when a
> > contact is closed, they are supposed to enter data. Problem is,
> > because it's a browser, they can just click the X mark and close the
> > window, which leaves the contact waiting for data to move to another
> > state. If I could pop the window back up and request the data again,
> > that is acceptable, but I haven't yet figured that out.

>
> You need to properly handle that on the server end since you also have to
> deal with contingencies like the client machine crashing, the client
> machine losing power, or a network outage, all of which could result in no
> data being entered at a particular state in the application.


Yes, the server side needs to be addressed as well (as you note, clients
purposely closing the window isn't the only issue...) but the big
problem is call transfer. When there's an outage, the switch drops the
call, but when the client closes the window, the call is in limbo on the
switch...
 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      12-24-2003
danny wrote:

>> This is the web. You can't force the user to do anything.

>
> Actually, It's not for an internet application.


If its browser based, then its as good as.

>> Make the
>> application robust enough to survive the user doing the unexpected.


> Gee thanks... I thought that's what I *WAS* doing...


where the application is the code you execute on the server, not on the
client which is beyond your control (at least if you use a normal web
browser).

--
David Dorward <http://dorward.me.uk/>
 
Reply With Quote
 
@SM
Guest
Posts: n/a
 
      12-24-2003
danny a ecrit :
>
> In article <>,
> says...
> > danny a ecrit :
> > >
> > >
> > > It's a call center application, and when a contact
> > > is closed, they are supposed to enter data. Problem is, because it's a
> > > browser, they can just click the X mark and close the window, which
> > > leaves the contact waiting for data to move to another state. If I
> > > could pop the window back up and request the data again, that is
> > > acceptable, but I haven't yet figured that out.

> >
> > supose your funtion to send your data is
> > function sendData(){ blah blah ; DataOk=1;}
> >
> > var DataOk =0;
> > </script></head>
> > <body onunload="if(DataOk==0) sendData();"
> >
> > Would works with IE

>
> Would this prevent the window from unloading? Or would I have to handle
> that someplace else?


that would launch your function about your state data
after closing the window
with IE it could (sometimes) works if IE is closed
(doesn't work on an alt+shift+del or alt+F4 )

to re-open the window try :

function reBack(){
open.window(self.location);
alert('You have not completed the Data question');}

<body onunload="reback();">

or
<body onunload="setTimeout('reback()',200);">
 
Reply With Quote
 
@SM
Guest
Posts: n/a
 
      12-24-2003
"@SM" a ecrit :
>
> to re-open the window try :
>
> function reBack(){
> open.window(self.location);
> alert('You have not completed the Data question');}
>
> <body onunload="reback();">
>
> or
> <body onunload="setTimeout('reback()',200);">


Take care you will never more can quite this page !

You have to fix a conditional before

<body onunload="if(!myData) reBack();">

*myData* would be a global variable
myData = false;
changed to "true" by your function about your Data
when it is called
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need JavaScript to prevent people from closing a browser window Daniel Walzenbach ASP .Net 9 01-25-2010 09:33 AM
Closing popup window when closing parent window? =?Utf-8?B?Vk1J?= ASP .Net 3 02-15-2007 08:29 AM
Closing child window when opening a new Window Patrick Olurotimi Ige ASP .Net 2 12-14-2004 04:59 AM
Closing child window and refreshing Parent window automatically =?Utf-8?B?U2lsZWVzaA==?= ASP .Net 4 10-14-2004 02:01 AM
Closing child window WITHOUT closing parent thomas Javascript 0 10-23-2003 04:10 PM



Advertisments