Has anyone else noticed that buttons rendered with button_to_function
in Safari don’t work when you hit return? Works find in firefox. Is
there a know work around?
Hm… I just did a quick test and when I tabbed to the button and
pressed return, it submitted the form. Maybe you have something else
amiss?
Safari 3.0.4 (523.12) on Mac OS X 10.4.11 and Windows XP SP2.
Peace,
Phillip
On Dec 9, 2007, at 9:11 PM, Pat wrote:
Has anyone else noticed that buttons rendered with button_to_function
in Safari don’t work when you hit return? Works find in firefox. Is
there a know work around?
Gack…
Sorry, Pat. Just looked a little closer and saw that you said
button_to_function, not button_to. That’s a different story, but I
do have some information for you. I ran into the same problem last
night and it’s because there’s no form element. According to someone
on the web-dev Apple list, it’s a bug in Safari (which I have not yet
filed…Maybe we both should ). You can get around it in one of
two ways:
- put a form around the
- change it to …
Granted, that means you will have to create your html without using
button_to_function, but it will work.
Here’s the text an the exchange I had last night/this morning:
===============================================
Thank you Alexey and Tom. I tried two things:
- changing <input type=“button” …> to
and
- putting a around the input.
Both achieved the desired result, but I have to ask which way is more
correct? My specific scenario is I have a login form with two
buttons, one for “Login” and one for “Forgot Password”, each calling
a JavaScript function. In the case of Forgot Password, it’s a simple
redirect with
window.location = url;
But for the login form, I submit the username and password via
Prototype and AJAX, so when the user enters incorrect login
credentials, I update the specific portion of the screen by rendering
a partial (this is a Rails app). I chose to do this so I wouldn’t
have to redraw the whole page again because it has flash animations
and graphics (trying to keep it snappy).
In addition to the previous two examples, I suppose there is a third
possibility:
- Use two forms, one for the login piece and one for the Forgot
Password button
Which way would be considered the closest to correct?
Peace,
Phillip
On Dec 9, 2007, at 6:02 AM, Tómas Ãrnason wrote:
Try using a button-tag instead, might work. As you don’t have a form-
element surrounding the input-button.
Also, check out the JavaScript console in Safari and check the output…
Tom
On Dec 9, 2007, at 2:33 AM, Alexey Proskuryakov wrote:
on 09.12.2007 07:37, Phillip K. at [email protected] wrote:
When the button is highlighted, IE 6 and FireFox 2.0.0.11 (Windows
and Mac) both fire the onclick event when the Enter/Return key is
pressed. Safari 3 (neither Windows or Mac) doesn’t.
Safari simulates onclick on form’s submit element, not the button
(and if
there is no submit, it doesn’t simulate a click). Please file a bug via
http://bugs.webkit.org!
doesn’t have this problem AFAICT.
Is there some special way of getting that to work in Safari without
resorting
to trapping the key in an onkeypress event?
Besides using , I would suggest onkeydown over onkeypress,
although in this specific case it doesn’t make a difference.
- WBR, Alexey Proskuryakov.
Original Message:
Hi all. First post to this list. I apologize if this is not a unique
question. I’ve been searching for the past hour, but have not found
an answer so I thought I’d try here.
I have a simple page
When the button is highlighted, IE 6 and FireFox 2.0.0.11 (Windows
and Mac) both fire the onclick event when the Enter/Return key is
pressed. Safari 3 (neither Windows or Mac) doesn’t. Is there some
special way of getting that to work in Safari without resorting to
trapping the key in an onkeypress event?
Peace,
Phillip
In addition to my second message, I also found this link on the
WebKit Bugzilla:
http://bugs.webkit.org/show_bug.cgi?id=14382
It’s not the same test case, but the bug is the same. However, part
way down the comments, a person named Dave Hyatt states
========== begin comment ===========
There is no bug on Mac. This is really a Windows port issue.
On the Mac, spacebar activates a button, and Enter activates the
default button
in dialogs. The two are distinct. This is expected behavior to a Mac
user.
On Windows this is not the case (Enter always activates the focused
button, and
only activates the default button if another button is not focused).
========== end comment ===========
Since I’m new to the Mac (past 7 months or so), this was new to me.
I did test my case again using the space bar and it worked fine.
Go figure.
Peace,
Phillip
hmmm, well here is my exact code. See anything?