I have a lightwiehgt plugin to firefox which needs to inject a script into the HTML. The code looks like this:
var head = document.getElementsByTagName("head")[0];
var newscrpt;
newscrpt = document.createElement('script');
newscrpt.type = "text/javascript" ;
newscrpt.src = "http://blabla.com/...";
newscrpt = head.appendChild(newscrpt);
The problem is that document.getElementsByTagName("head")[0]
returns 'undefined', and checking document.getElementsByTagName("head").length
is 0.
It currently executes on the browser document.onLoad event but I also tried calling it from window.setTimeout
to make sure it is not a problem with loading synchronization, but the same happens.
Any ideas from anyone? Thanks!