I started out with hello world application from google documentation to write a chrome extension. http://code.google.com/chrome/extensions/getstarted.html
I simply modified the popup.js to be:
var span = document.createElement("span");
span.innerHTML = "<b>blah</b>";
alert(document.head);
alert(document.body);
document.body.appendChild(span);
I expect this to display “blah” in my popup but I am getting document.body as null. I am new to js and chrome and my trying to figure out whats going on here. What am I doing wrong?
When the closing script tag is encontered, the corresponding code is directly evaluated.
Since
background.jsis loaded in the head,<body>does not exist (yet). Hence,document.bodyisnull.