I have a lightwiehgt plugin for firefox that needs to insert a script in HTML. The code is as follows:
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 it document.getElementsByTagName("head")[0]returns 'undefined' and the check document.getElementsByTagName("head").lengthis 0.
It is currently being executed in the document.onLoad event of the browser, but I also tried calling it from window.setTimeoutto make sure that this is not a problem with loading synchronization, but the same thing happens.
Any ideas from anyone? Thank!
source
share