Use Javascript Alert To Keep Users On A Page
<p>I am creating an internal web based application that will not be the target audience of the web.</p>

<p>I understand the frustration of alert boxes and forcing people to do certain things.</p>

<p>With that said, what I am attempting to do is create a javascript function, that unless a user clicks a link on a specific page, if they try to navigate away from the page other than using a link on the page, I would like to alert them and say, sorry you need to click the appropriate link to exit.</p>

<p>What my issue is, is that I need to lock out fields, and what I can do when a user hits an edit page, im going to write to a table that user to the lockoutuser colum. If a value exist, that user can access the record if it is null, it means no one is editing the record. If someone clicks to go into that record they lock it out, my means of updating the lockoutuser colum could be ajaxy on unload of the page, but the page could be unloaded for 2 reasons, 1 the edit form is submitted or the user leaves the page.</p>

<p>An alert that would say, sorry you can leave this record without clicking the big red button that says unlock, and force the user without refreshing to stay on the page.</p>

<p>I understand the machine could crash and or an alt f4 or a brute end task on the browser will still leave me other work to unlock the record</p>
