Tags:
create new tag
, view all tags
Having just lost a browser window full of unsaved edits to another application that kindly opened a link for me and stole my window, I thought I'd float the idea of, for the javascript enabled folk among us, a popup that warns the user from going away from a page in edit mode.

I have no practical knowledge of programming this but I figured lots of people would have and that someone might have seen this in a webmail client such that we could reappropriate the code.

Offers, anyone?

-- MartinCleaver - 19 Jul 2003

http://www.experts-exchange.com/CXO/Web/Web_Languages/JavaScript/Q_20413097.html

-- MartinCleaver - 20 Jul 2003

This is probably BackFromPreviewLosesText again - there's not much that TWiki can do to control IE re-using browser windows for another URL. Check BrowserIssues to be sure you have the right settings, as this should only happen very infrequently if your cache settings are correct. The best workaround is to use a different browser for TWiki rather than InternetExplorer (I'm guessing that's what you are using, since you didn't mention this.)

There is an IE setting that says 'don't re-use windows' or 'use a new window' that would help avoid this. I don't think that JavaScript would help, particularly if the user has this turned off, since it's not JavaScript causing this problem anyway.

-- RichardDonkin - 21 Jul 2003

Just a short note ... this isn't IE in particular. This would happen to any browser, i.e. my Mozilla and IE are equally prone to do this. At least in Mozilla it's easy to quickly open another empty tabbed page and then click the link that would otherwise hijack the browser. The same trick works in IE, by the way.

This isn't a big problem with mozilla/netscape because they remember the values in form fields. When you hit 'back' everything is just the way you left it.

-- BradMace - 20 Aug 2003

Addition:

Here's a quick draft of the javascript that would be needed:

<script>
function DontCloseMe() {
   if (window.confirm("Are you sure you want to abandon this edit?"))
   then
      /* let the browser open the new location */
   else
      /* don't let the browser open the new location */
}
</script>
<body onunload="DontCloseMe();">
</body>

The trick is what to put instead of the /*comments*/. The first comment should really not do anything at all. The second should cancel the attempted navigation.

A problem with the onunload method is that it will always fire when the user leaves the page, i.e. also when he leaves it by saving/cancelling the edit! This can be fixed by letting the dontcloseme() check for a variable, which the save/cancel buttons could disable to stop the javascript.

-- TorbenGB - 22 Jul 2003

Great contribution Torben, that's exactly what I meant. smile A couple of things we have to think about:

  1. Use of TWikiVariables instead of hardcoded langauge content
  2. How this interacts with skins. I am keen to ensure this doesn't become another ConsolidateFunctionalityFromSkins issue.

I spoke to Torben on ICQ and TWikiIRC about this - he's going to knock up a quick demo for us.

-- MartinCleaver - 22 Jul 2003

My point above was that the 'abandon this edit' question is pointless if BackFromPreviewLosesText is working, which it should be (for both IE and Mozilla) - the user just hits the Back button to retrieve the original edits. It would be much simpler to just check your cache settings and the options to avoid re-use of windows before adding a layer of complexity to work around these issues... Having extra questions in popup boxes every time another window opens is much less clean than avoiding the issue entirely.

-- RichardDonkin - 22 Jul 2003

I think Safari 3 does this now. If you have entered any text in a form, then attempt--by any means--to navigate away from that page, Safari will warn you and give you the opportunity to cancel.

-- DavidWolfe - 02 Sep 2008

Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r10 - 2008-09-02 - DavidWolfe
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.