Wednesday, 21 August 2013

Appending a script file contained inside a firefox extension to html head using JavaScript

Appending a script file contained inside a firefox extension to html head
using JavaScript

I was wondering if it's possible in a firefox extension to append a script
element to the head of an html document which takes it's src from a js
file stored within the extension?
I am currently doing the following, but would be much better to be able to
package what I need within the extension:
var head = content.document.getElementsByTagName('head')[0];
var jqscript= content.document.createElement('script');
jqscript.type= 'text/javascript';
jqscript.src=
'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js';
head.appendChild(jqscript);
Thanks

No comments:

Post a Comment