Skip to content

Display Javascript Object In WebPage Without Knowing Its structure

I want to Display javascript document object in webpage, in the same way it is displayed in console as object opening as dropdown. Is there any way by which we can display a javascript object on webpage without knowing its structure in the same way as console does?

Answer

Check this out:

<html>
<head>
    <script type="text/javascript">
        for(var prop in document)
            document.write(prop + ' = ' + document[prop] + '<br>');
    </script>
</head>
<body></body>
</html>