Advertise with us

JavaScript Document.Head is Null

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:

   <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>
   function load() {
    <iframe src="" width="300" height="400" frameborder="0" scrolling="no" allowtransparency="true" id="myFrame" onload="load()"></iframe>

Any help will be appreciated.

Last updated:9/3/2013 7:56:21 AM

1 Answers

Sumit Kesarwani
Sumit Kesarwani

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];

Last updated:9/3/2013 7:56:21 AM