Pet Firefox peeve

1:32 pm General

Have you ever been working on a blog entry in firefox, and hit Ctrl-W instead of Ctrl-X by accident (or by habit)?

I don’t know how many times it’s happened to me, but it’s often. And always annoying.

Recently, I noticed a dialog when I tried to close on some website I can’t recall – “you have unsaved work, are you sure you want to close the window?” – I don’t know whether it was some Javascript in the page, or whether it was Firefox patched by Ubuntu, but I was very grateful.

Is this possible? Can I please stop losing unsaved work when there’s a form with text inputs on the page I’m closing by accident?

19 Responses

  1. meastp Says:

    Well… A dialog that asks me if I want to exit always shows up when I have more than one tab open. It is a default setting. Check your preferences if you have turned it off…

  2. Johannes Berg Says:

    Galeon (and as far as I know epiphany) do this, sometimes annoying when some javascript fills in a form for you, but it does seem to work.

  3. stro Says:

    Yes Epiphany does this if you leave unsubmitted text in a textbox form field.

  4. Johannes Gijsbers Says:

    Epiphany does this out of the box for all websites.

    Blogger has some JavaScript that does it too, maybe that was what you saw?

  5. Jeroen Asselman Says:

    Try (if I am not mistaken):

    var Navigate = false;
    var NavigateMessage = “You have unsaved work”;

  6. Dave Neary Says:

    meastp: I’m not closing the entire window, just closing a tab with Ctrl-W – which typically doesn’t give any warning at all.

    Thanks all for the Galeon tip – I will also need something that works on Windows, though…

    Jeroen: Try it where?

  7. Emil A Eklund Says:

    It’s javascript, catch the onbeforeunload event.

  8. Jeroen Asselman Says:

    Sorry, that was a bit to sparse

    var confirmClose = true;
    function confirmNavigate()
    {
    if (confirmClose)
    return “Do you want to save your work?”;
    }

  9. Jeroen Asselman Says:

    Hmm, wasn’t aware that any html stuff would be removed.
    In your body element do a:
    onbeforeunload=”return confirmNavigate();”

  10. Stuart Langridge Says:

    You might find http://www.arantius.com/article/protect+textarea useful, which is a GreaseMonkey script to do just what you’re looking for. (It only applies to textareas, not one-line input boxes, but it’s trivial to hack one-line text support in for a JavaScript person.)

  11. nananana Says:

    You know, ctrl-w is supposed to do exactly that. On all the modern sane applications, without ANY whining. Ever. You’re just a skilless noob.

  12. Stu Says:

    Yeah I always do this, esp after using nano (where ctrl-w is find)… What might be nicer with the prevelance of gui editors with similar shortcuts would be for nano to adopt key shortcuts that will be familiar to users of gui apps

  13. adel Says:

    that would be so evil if kids got hands on

    it’s simple javascript callback “onunload” event, write function that checks forms for unsaved data and/or cancel/continues navigation

    kids can use this to make you never ever leave the site

  14. Ryan Paul Says:

    This used to happen to me all the time as well. It’s very, very frustrating. I finally ended up enabling emacs shortcuts in Firefox. Now, when I hit ctrl+w while typing in a text box, it erases a word rather than closing the window. To find out how to do that, go here:
    http://kb.mozillazine.org/Emacs_Keybindings_(Firefox)

  15. SPr Says:

    try undoclosetab extention
    http://mozilla.dorando.at/readme.html
    using this you can undo any ctrl-w

  16. Alex Jones Says:

    Guh… just compile Epiphany for Windows and be done with it. 😛

  17. cs Says:

    blogger does this when you are writing a comment iirc

  18. nibblesmx Says:

    you just gave me an idea for a new firefox extension, tnx!

    and btw, is the onbeforeunload event.

  19. Olivier Says:

    I saw this for the first time on a comment on blogger.

    To try it : go to a blogger blog, go to the comment writing page, start to write and then try to go to another page.