I wish to enumerate all the available functions of various JavaScript objects and even HTML elements created in JavaScript. For example the following works great in both Chrome and FireFox:
<html>
<body>
<script>
var object = document.createElement( "select" );
for( var prop in object )
{
document.body.innerHTML += "" + prop + "; // " + typeof object[prop] + "<br/>";
}
</script>
</body>
</html>
This outputs all the properties of the object including the functions available to that object, e.g.:
...
insertAdjacentHTML; // function
insertAdjacentText; // function
insertAdjacentElement; // function
getAttribute; // function
setAttribute; // function
removeAttribute; // function
getAttributeNode; // function
...
However this will not work in IE9, all you get are the string/number/object properties and never any of the function properties.
My question is how can I discover at run time what function names are exported by an object in IE9?
Many thanks in advance.
UPDATE: adding a doctype gets this working as expected.
<!DOCTYPE html>
<body>
<script>
var object = document.createElement( "select" );
for( var prop in object )
{
document.body.innerHTML += "" + prop + "; // " + typeof object[prop] + "<br/>";
}
</script>
</body>
</html>
That code looks fine to me, and works OK in IE9 here.
http://jsbin.com/ivukus/edit#preview