Back/Forward and JS + XHR + URL Manipulation

Steps to reproduce:

  1. Go to your Facebook inbox page, pick a random message, and start typing a reply
  2. Halfway through, realize you want to read a different message before finishing this one.
  3. ‘Accidentally’ left-click instead of middle-click the link at the top for the inbox.
  4. Hit escape to stop the load so as to be able to still have the text you type

Expected result:

Stop loading the inbox page, get to keep your written stuff

Actual result:

This is JavaScript executing. There’s no stopping it from throwing away your text anymore by returning to the inbox – and what’s worse, the back/forward history is so confused by what’s going on (as you hit escape) that it won’t be able to take you back to the reply page and restore your message to the textbox (as back/forward generally does in Firefox). Congrats, you just lost N minutes worth of typing, and who knows what kind of brilliant ideas!

Question to the Lazyweb: whose fault is this? Can it be fixed? How? (Yes, I’d prefer to just use email all the time, too, but unfortunately that’s not always an option, and I’m sure there are webmail implementations which have similar problems, especially once you turn off automatic draft saving)

8 thoughts on “Back/Forward and JS + XHR + URL Manipulation

  1. To the previous commenter: thanks, but I really *am* also trying to pose the first question: whose fault is this? In principle, Firefox does save form contents for back/forward. It’s the JS and XHR stuff that’s messing with some of the assumptions that code is making, I guess, and I’m wondering if the JS/XHR could be done in such a way that the problem won’t occur, or that we can change some of the assumptions that Firefox itself is making and have its own save/restore work for this case as well.

  2. > and I’m wondering if the JS/XHR could be done in such a way that the problem won’t occur,

    Yes. gmail does just that, last I checked.

    > or that we can change some of the assumptions that Firefox itself is making

    Hard to say without a testcase (and no, I’m not creating a Facebook account, sorry).

  3. It’s my understanding that it is possible to us js to send “new page event”s to the browser, and that when that happens firefox does save form data. Of course, the js can overwrite that data.

    Gmail doesn’t let you change pages within its site with unsaved data, but i feel like that’s new, and that what used to happen was that my old messages would be there if i clicked “back.” Also see the way google reader totally dominates that tabs history.

    I guess i’m blaming the website, if for no other reason than that they really can throw up a dialog saying “are you sure?” Although if there is no javascript “i’m going to a new page” event, there probably should be.

  4. I vote Facebook’s fault.
    If I navigate away from a message in gmail it sees that I haven’t saved or sent the message and it prompts me.
    Facebook doesn’t have to save messages, but it can sure detect if I’ve sent it yet and prompt me about it.

  5. Dmose: Sure. Sometimes, at least for me, one is able to find someone on Facebook, MySpace, LinkedIn, or what-have-you. However, email addresses need not be visible at that time. Of course, you can ask for them, but that requires sending such a message (chicken-egg problem, in a sense). Furthermore, on some sites such as dating sites, the exact point is that you send messages on the site, somewhat anonymously, without giving away your personal email address (or such is what I’ve understood about them – I’m afraid I don’t actually use dating sites, so I have no first-hand experience of that system). Finally, group pages on social networking sites provide an easy way to have topic-centred discussions with a group of people, without having to start a webserver, emaillist or something similar. The same problem occurs there.

    All these cases can be essentially done in email by creating eg. temporary addresses that can be removed so as to prevent correspondence via them, email lists and other technical solutions – but this requires a certain amount of effort and technical knowledge by the person concerned, which means they are not solutions for most non-technical persons.

    Boris: I didn’t expect you to create a Facebook account, sorry if I gave that impression. It’s a general problem. Facebook does gmail-like things in having #anchors to get back-forward history, and that’s what breaks here, but I’m aware that you will need a working testcase to be able to do anything. I will file a bug when I have one – right now I’m fairly swamped with getting started at uni, but that should be over in a week or two, and then I’ll try to get a bug + testcase going. Thanks for your input! 🙂

  6. Hello to all 🙂 I cant understand how to add your site in my rss reader. Help me, please

Comments are closed.