views:

377

answers:

1

I am actually debugging an application for IE8 (after IE6, IE7 now IE8). I went received a bug in one of my interface when we were doing an action on a dropdown and I wondered why it wasn't happening before. I finally found out that a drop down (or a select) calling a method named "role()" directly wasn't supported.

Does anyone know why?

Here's an example of the bug:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<script type="text/javascript">
function rolea(dropdown){
    alert("value");
    //role();
}

function role(){
    alert("value");
}
</script>
</head>
<body>

<select onchange="role()" name="select1">
    <option>a</option>
    <option>b</option>
</select>
</body>
</html>

If we call "role()" it does not work and I receive the error : Line: 18 Error: Object doesn't support this action

When I call "rolea()" it works and the JavaScript alert shows up. And also if I try to call "role()" from "rolea()" it also works.

+4  A: 

IE8 supports assistive technology, which defines the accessibility features through "role" and "aria" attribute at the nodes. Role is reserved word in IE, inside the DOM scope.

If you do <select onchange="alert(typeof(role))" name="select1"> you will see that this is a string. Trying to execute string as a function causes error. (To get the alert work, remove your role function declaration and see it in action).

You can read here more http://dev.w3.org/html5/spec/Overview.html#annotations-for-assistive-technology-products-aria

nemisj
Wow, thank you for the explanation.
Nordes
I would have expected in IE8 "IE8 standards mode" that this kind of hacky *magical* scope attribute stuff would have gone away. ugh... oh well.
scunliffe