<body>
<script type="text/javascript">
function name(firstname)
{
alert("Your firstname: " + firstname);
}
</script>
<form>
<input type="button" value="Do it" onclick="name('aaron')"/>
</form>
</body>
This will not work in Chrome/IE8. IE8 states Object doesn’t support this action. It has to do with the name of the function being name. If I change the name of the function to people it works…what gives?
It’s not a reserved word, and it’s not a clash with
window.name. There are problems with using awindowproperty name as a global variable in IE, but it’s OK as long as you have declared them globals using thevarorfunctionkeywords as you have here.What you have here is a strange—and, as far as I can see, undocumented—IE quirk (copied by WebKit) where, in event handlers declared via inline attribute, the properties of the target element are treated as local variables. This is presumably so you can write code like:
‘cos saying
this.nameis too hard, apparently. Once again IE trying to be “convenient” causes weird unpredictable bugs.This is just another reason not to use inline event handler attributes. Without them:
works fine.