En réponse à Laurent vilday qui écrivit, en date du : 6/09/07 0:02, le
message suivant :
> Oups, nouvelle édition rectifiant un précédent post annulé. Mais on sait
> tous à quel point les annulations sont hummm disons aléatoires. Prière
> d'ignorer le précédent qui raconte un paquet de bêtises
shut !
Tommache ! y m'plaisait bien :-)
> Mickaël Wolff a écrit :
>> Bruno Desthuilliers a écrit :
>>> Je confirme.
>>> - sous FF, utiliser:
>>> document.getElementById('mon_lien').onclick();
>>> - sous IE, utiliser:
>>> document.getElementById('mon_lien').click();
>>
>> Ce qui est amusant, c'est que seul HTMLInputElement.click() est prévu
>> par la recommandation du W3C
>> <http://www.w3.org/TR/DOM-Level-2-HTML/html.html>
>
> <div id="lolo"></div>
>
> <form>
> <input type="text">
> <input type="button">
<textarea></textarea>
> </form>
>
> <script type="text/javascript">
> window.onload = function()
> {
> var E = document.getElementById('lolo');
> alert('1) ' + typeof E.onclick + '/' + typeof E.click);
>
> E = document.forms[0].elements[0];
> alert('2) ' + typeof E.onclick + '/' + typeof E.click);
>
> E = document.forms[0].elements[1];
> alert('3) ' + typeof E.onclick + '/' + typeof E.click);
E = document.forms[0].elements[2];
alert('4) ' + typeof E.onclick + '/' + typeof E.click);
> };
> </script>
>
>
> FX2 :
> 1) undefined/undefined // OUI / OUI
> 2) undefined/function // OUI / non
> 3) undefined/function // OUI / OUI
4) undefined/undefined
> IE7 :
> 1) object/object // non / non
> 2) object/object // non / non
> 3) object/object // non / non
IE-Mac :
1) 2) 3) 4) object/function
iCab3.0.3
1) 2) 3) 4) undefined/function
Safari2
1) object/undefined
2) undefined/function
3) undefined/function
4) object/undefined
> Op9 :
> 1) object/undefined // non / OUI
> 2) object/function // non / non
> 3) object/function // non / OUI
Op9-Mac
1) undefined/undefined
2) undefined/function
3) undefined/function
4) undefined/undefined
NC4.5 :
... ? ...
Et maintenant ? avec tous ces cas ... keféton ?
> D'ou provient le onclick pour Opéra, je ne sais pas. Je suppose une
> autre tentative d'émulation du comportement du IE.
>
> La RFC stipule, je cite : - Method click: Simulate a mouse-click. For
> *INPUT* elements whose type attribute has one of the following values:
> "button", "checkbox", "radio", "reset", or "submit". -
Oui, bon, les brouteurs simplifient peut-être par form.elements ?
bien que pour certains ... et le textarea ?
> M'enfin tout cela ne m'inspire comme souvent que ceci : sniff sniff
ou bouhaaa! bouhaaa!