I want to list 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 displays all the properties of the object, including the functions available to this object, for example:
... insertAdjacentHTML; // function insertAdjacentText; // function insertAdjacentElement; // function getAttribute; // function setAttribute; // function removeAttribute; // function getAttributeNode; // function ...
However, this will not work in IE9, all you get is the string / number / object properties and never has any function properties.
My question is, at runtime, can I find out what function names are exported by an object in IE9?
Thank you very much in advance.
UPDATE: adding doctype allows you to work 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>
source share