[Javascript] Re: Invoke onclick event of one button from clicking a second button
Cutter (javascript list)
javascript at theblades-family.com
Tue Sep 10 07:36:34 CDT 2002
From Javascript: The Definitive Guide, David Flanagan
The click() method of a form element simulates a mouseclick on the form
element but does not invoke the onclick event handler of the element
Cutter
George Tsang writes:
> Greetings,
>
> I have set up the following:
>
> <button id="abutton" onclick="alert('A clicked')">A</button>
> <br>
> <button id="bbutton" onclick="stuff = document.getElementById
> ('abutton'); stuff.click()">B</button>
>
> Result:
>
> By running this on IE5.5 and by clicking the 'B' button, I can invoke
> the alert message belonging to the onclick event of the 'A' button.
>
> However, this does not work in Netscape 6. The Netscape Javascript
> Console posted the error: "stuff.click is not a function".
>
> I changed the button tag attributes of the 'B' button to:
>
> <button id="bbutton" onclick="stuff = document.getElementsByTagName
> ('button'); stuff[0].click()">B</button>
>
> Result:
>
> IE5.5 works. Netscape 6 still does not work. The Netscape Javascript
> Console posted the error: "stuff[0].click is not a function".
>
> Is there anything else one can do to resolve this problem.
>
> Thanks.
More information about the Javascript
mailing list