If the element you want to fire a click event on is a link (<a...>
element) you can use
eval(element.href);
- which will "do the click". This is particularly great for e.g. asp.net
postbacks, where the location value is something like
"javascript:__doPostback('arg','arg');"
In IE, the ".click()" will work, but not in FF and other gecko-based
browsers. See this link:
https://developer.mozilla.org/En/DOM/Element.click
- in the notes section:/
/
/The click method is intended to be used with INPUT elements of type
button, checkbox, radio, reset or submit. Gecko does not implement the
click method on other elements that might be expected to respond to
mouse--clicks such as links (A elements), nor will it necessarily fire
the click event of other elements. /
/Non--Gecko DOMs may behave differently/
/Jan
On 20-02-2009 13:32, marioosh wrote:
> hello;) i have code like below. I need to simulate click on #log_in
> button when i press enter on input fields. My code doesnt work. Why ?
> What can i do to make this works ?
>
> [cut]
> $(this.elContainer).down('#log_in').observe('click', function()
> {
> this.login();
> }.bind(this));
>
>
> $(this.elContainer).select('input').each(function(el){
> el.observe('keypress',
> function(event) {
> if(event.keyCode ==
> '13') {
>
> $(this.elContainer).down('#log_in').fire('click');
> //this.login();
>
> //Event.stop(event);
> }
> }.bind(this));
> }.bind(this));
>
> [cut]
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---