Home > DeveloperSection > Forums > JavaScript Document.Head is Null
Ankita Pandey
Ankita Pandey

Total Post:183

Points:1285
Posted on    September-03-2013 7:38 AM

 JavaScript JavaScript 
Ratings:


 1 Reply(s)
 2704  View(s)
Rate this:

Getting an error when running the following code in IE 8, but not in other browsers:

'document.head' is null or not an object

Here is my code:

  <!DOCTYPE html>

   <html>

   <head>

   <meta charset="utf-8" />

   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

   <link rel="stylesheet" type="text/css" href="style.css" media="screen" />

   <script type="text/javascript" src="respond.min.js"></script>

    <script>

   function load() {

    document.getElementsByID("myFrame");

    }

   </script>

   </head>

   <body>      

    <iframe src="http://instagram.com/p/bTlK6CRNcL/embed/" width="300" height="400" frameborder="0" scrolling="no" allowtransparency="true" id="myFrame" onload="load()"></iframe>

</body>

</html>

Any help will be appreciated.



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    September-03-2013 7:56 AM

Hi Ankita,

That's because IE8 doesn't support it. It's a new feature of HTML5. You could use:

var head = document.head || document.getElementsByTagName("head")[0];


Don't want to miss updates? Please click the below button!

Follow MindStick