javascript - Pressing Escape under Firefox kills my Ajax requests. I'd like to prevent this -
i'm developing web application requires long-running ajax requests. unfortunately, under firefox, pressing escape during request has drawback of killing request , information holding. rather annoying, can lead sorts of nasty complications if happens @ wrong time. therefore, deactivate feature.
my first reflex intercept keypresses @ boundaries of <body>, ensure not reach window. purpose, installed [keypress] event handler, events [keychar] 27, , had invoke [stoppropagation] , [preventdefault]. , time, looked working.
then, realized wouldn't work when user hadn't clicked anywhere on window, <body> event handlers never received event. tried attach handler <document> or <window> no avail, ended adding [load] event handler , had force focus <body>. , time, looked working.
then, realized when user editing <input>, reason, once again, <body>, <document> or <window> event handler never seem receive event. so, added yet [keypress] handler, intercepting [preventdefault] on <input> when [keychar] 27.
for moment, looks it's working. however, history of bug in application, i'm tad pessimistic.
so, i'm wondering if there's better -- , reproducible -- method. recall bug seems appear in ff, i'm quite willing take ff-only approach here.
thanks
i'd worried other nasty complications happen when users choose bookmark or otherwise navigate away in middle of request. might want @ why you're using long running requests , see if that's can change...
if isn't can change (or if can) should @ why requests aren't fault tolerant. there way put communication transactions, , roll latest 1 if connection interrupted?
Comments
Post a Comment