4

I have some Javascript code on a form submit that greys out a table of data and overlays a loading image to indicate that the reload is occurring.

The problem is that if the page reload is cancelled by the user, the table stays greyed out. I would like to notice if the page submit was cancelled, and if so, fade the table back in and remove the overlay.

My question is: Is there an event I can bind to using either straight Javascript or jQuery for when loading of a new page is cancelled?

I've googled quite a bit for something, but if there's an answer, I can't see it amidst the mass of people asking how to cancel a submit action.

Shawn D.
  • 7,895
  • 8
  • 35
  • 47

1 Answers1

0

How about having an event handler for the user cancel that undoes the grey out? I.e. rather than waiting to be alerted of the cancel, become the handler of the cancel.

DWright
  • 9,258
  • 4
  • 36
  • 53
  • What do you mean, handle the keyboard event for esc? – Shawn D. Jan 23 '13 at 17:30
  • Ah, I see. So you're saying that the user cancels the page reload with a browser mechanism, not via the UI of your page, per se. – DWright Jan 23 '13 at 18:02
  • Yes, submit the form, then hit escape. The page load stops, but the table is left greyed out. – Shawn D. Jan 23 '13 at 18:15
  • Ok, I hadn't understood the question at first, sorry. Take a look [at this discussion](http://stackoverflow.com/questions/1794047/can-javascript-detect-when-the-user-stops-loading-the-document). It does not answer your question yet, but contains some discussion that may provide helpful pointers toward a solution – DWright Jan 23 '13 at 18:43
  • when you say "loading of a new page is cancelled", what do you mean? the user hits the STOP button in the browser? – hanzo2001 Dec 14 '13 at 11:28