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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onclose event

Status
Not open for further replies.

okiiyama

IS-IT--Management
Joined
Jan 3, 2003
Messages
269
Location
US
When a user closes a window, or the browser window is forced to close, I would like to have an event that would *somehow* execute a query to update a specific record. I would do a window.open that opens to the page that has the query code in it, but I don't want to take the chance that the user has a pop-up blocker.

The record that I'm updating has a lockid field. When its set to null the record is not locked, and can be edited by a user. So during onClose, I would like to unlock the record. Is this something I can do with javascript? I am using ColdFusion, if I should try something with CF.

Thanks.
 
the closest you could come would be utilizing a window.open from the onunload event but this is pretty much the most widely blocked form of popup window out there.

you could also add code to each link to check if a user is leaving the page, and if so, again call a window.open.

neither of these methods are very elegant - what if a user has disabled javascript altogether?

have you considered maybe a job that would run every x number of minutes to see if any updates have been made to the record, and, if none have, unlock the record from that perspective?

you could also potentially incorporate some AJAX to update a flag in the DB, setting the record as "actively being updated"...

just some thoughts...



*cLFlaVA
----------------------------
[tt]( <P> <B>)13 * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
you can try onunload calling a confirm dialog that when you confirm executes the query, cancel of the confirm would stop the closing of the window (i've seen this done before)
 
you've seen that done before? can you show me where? AFAIK, onunload will not prevent the closing of the window, but will simply allow you do show a message before the window is closed.



*cLFlaVA
----------------------------
[tt]( <P> <B>)13 * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
actually the confirm executes or doesn't execute the query, either way closes window sorry about the confusion. I can't give link to sample, on hedge fund extranet system
 
this prevents the browser from closing in IE

Code:
<SCRIPT LANGUAGE="JavaScript" EVENT="onbeforeunload()" FOR="window">
event.returnValue = "sure you want to close?";
</SCRIPT>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top