---
title: "JavaScript Document.Head is Null"  
description: "JavaScript Document.Head is Null"  
author: "Anonymous User"  
published: 2013-09-03  
updated: 2013-09-03  
canonical: https://www.mindstick.com/forum/1429/javascript-document-head-is-null  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# JavaScript Document.Head is Null

[Getting an error](https://answers.mindstick.com/qa/95244/why-do-you-keep-getting-an-error-message-ox800ccc0b) when running the following [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) in IE 8, but not in other browsers:

'document.head' is [null](https://www.mindstick.com/forum/33922/how-to-use-null-coalescing-operator-in-c-sharp) 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.

## Replies

### Reply by 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];


---

Original Source: https://www.mindstick.com/forum/1429/javascript-document-head-is-null

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
