Announcement

Collapse
No announcement yet.

warn user if leaving edited post page without commit

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • warn user if leaving edited post page without commit

    I wonder whether it is possible to warn a user that he is about to leave a "Post New Thread" or "Post New Reply" page without having submitted the changes ?
    Eg. "You have not committed your edits. Press Cancel to return to the page or Ok to go to new page"


    The warning dialog would only appear if the user had actually made any changes, otherwise the page exit is fine anyhow.


    Noticing that something has changed would be pretty easy I guess (just set a "dirty" javascript global whenever something happens in the wysiwyg)

    But noticing the page URL is about to change and optionally preventing that change - is that easy too ? It would have to be some kind of Javascript / DOM hack in a single place because I dont want to add intelligence to all outgoing links on the page.

    There are so many links on the Post New Thread page (and any vb page) that its easy to make the mistake of clicking one of them and poof, chances are you lose your edited changes when you follow them (you lose context, may close the window, browser may forget the cached text for post page etc.)

    I guess to some extent this issue would apply to any vb edit page that is "exited" with unsubmitted edits, but the post new thread / reply are the most used ones.

    Thanks
    Robert
    Last edited by rseidl; Wed 10 Sep '03, 12:37pm.
    Canoma - software for creating realistic 3D models from photographs - forum - examples

  • #2
    One (insufficient) solution

    Thanks to DHTML lab, where I found the following:

    Code:
    <script language="JavaScript">
    window.onbeforeunload = unloadprompt;
    function unloadprompt(){
    mess = "You will lose all information provided\nduring navigation of this site";
    return mess;
    }
    </script>
    This gives the dialog box:


    Works only in IE though not NS, others (?), where it will be ignored. It is also unfortunate that MS chose to have the function return a string instead of a boolean (want to follow link or not) which would have allowed me to detect whether user has made edits and only in that case put up the dialog (also I do not want the dialog when I press the submit button). As it is I think I wont use this solution as always popping it up is too annoying.

    Are there better ways ?
    Canoma - software for creating realistic 3D models from photographs - forum - examples

    Comment

    Related Topics

    Collapse

    Working...
    X