I have spent many hours chasing down a problem where if the user hits
control+enter in certain form fields, Firefox's "Downloads" window
opens (on Windows XP, but not Linux). I finally narrowed things down
to the following test case, which sets up a keydown listener on the
field that does a synchronous AJAX call. If I comment out the
Ajax.Request, the Downloads window does not open.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>test</title>
<script src="/javascripts/prototype.js" type="text/javascript"></
script>
</head>
<body>
<h1>test</h1>
<form action="/somewhere">
<input type="text" id="data1_id" name="data1">
</form>
<script type="text/javascript">
function keyHandler(event) {
Event.stop(event);
new Ajax.Request('/', {asynchronous: false});
}
Event.observe($('data1_id'), 'keydown', keyHandler);
</script>
</body>
</html>
I wonder if perhaps the problem has to do with the shortcut for the
Downloads window being control+J. J is the 10th letter, so perhaps in
some way control+J maps to a newline, which is perhaps issued (though
I don't see it) when hitting control+enter.
If the request is not synchronous, the problem doesn't happen.
If you use Firebug to set a breakpoint on the Ajax.Request line, and
condition it to not break on the control key, then you can hit control
+enter, and the script will stop just before executing new
Ajax.Request, but the Downloads window still opens.
I am quite mystified. Does anyone have any clues as to what the
underlying cause might be? Thanks,
--Paul
p.s. Someone is bound to want to point out that using synchronous
Ajax is a bad idea. I understand that.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---