Quantcast
Channel: Comments for Web Browser News and Reviews
Viewing all articles
Browse latest Browse all 3756

Comment on Onclick Javascript Does Not Work in Google Chrome and Firefox? by Lars Gunther

$
0
0

Better yet, don’t use this pattern at all. There is an implicit eval when you set a string as an event handler. Also, this example does not seem to be unobtrusive.

It seems that this is what you’re looking for (depending on the rest of the HTML):

[script]
document.getElementById(“the_button”).onclick = function () {
document.getElementsByName(“cSSid”).value = “”;
}
[/script]

Also note that IE in real standards mode will noot leak ids as global symbols in JavaScript. Thus the very first code does not work in any browser if you’re doing things right.


Viewing all articles
Browse latest Browse all 3756

Trending Articles