How to access document properties using W3C DOM method?


This IE4 document object model (DOM) introduced in Version 4 of Microsoft's Internet Explorer browser. IE 5 and later versions include support for most basic W3C DOM features.

Example

To access document properties using W3C DOM method, you can try to run the following code −

<html>
   <head>
      <title> Document Title </title>
      <script type="text/javascript">
         <!--
            function myFunc() {
               var ret = document.getElementsByTagName("title");
               alert("Document Title : " + ret[0].text );

               var ret = document.getElementById("heading");
               alert(ret.innerHTML );
            }
         //-->
      </script>
   </head>
   <body>
      <h1 id="heading">This is main title</h1>
      <p>Click the following to see the result:</p>

      <form id="form1" name="FirstForm">
         <input type = "button" value = "Click Me" onclick = "myFunc();" />
         <input type = "button" value = "Cancel">
      </form>

      <form d="form2" name="SecondForm">
         <input type = "button" value = "Don't ClickMe"/>
      </form>
   </body>
</html>

Updated on: 23-Jun-2020

64 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements