This is my current bookmarklet code.
if (1 == 1) {
var jQ = document.createElement('script');
jQ.type = 'text/javascript';
jQ.onload=runthis;
jQ.src = 'http://www.domain.com/jquery-1.5.2.min.js';
document.head.appendChild(jQ);
}
I want to call multiple jQ.src. I tried this however it doesn’t work on some sites.
This is my current bookmarklet code.
if (1 == 1) {
var jQ = document.createElement('script');
jQ.type = 'text/javascript';
jQ.onload=runthis;
jQ.src = 'http://www.domain.com/jquery.js';
jQ.src = 'http://www.domain.com/jquery2.js';
document.head.appendChild(jQ);
}
On some sites it works and other it doesn’t Any insight?
Thanks!
Are you sure that works on some sites? I think you’re just getting lucky and picking up the site’s already loaded jQuery.
Anyway, if you want to add two JavaScript files then you’ll have to append two script tags:
Also note that the
onloadis only on the second one since you presumably need both JavaScript files loaded beforerunthiswill work.If you’re loading jQuery, you might want to check if the page has loaded it already:
Adding a
jQuery.noConflict()call might be a good idea too, the page might be using$for something else so forcing it to be jQuery could break the page.