开发者

Include JavaScript File in a Bookmarklet

开发者 https://www.devze.com 2023-03-01 04:31 出处:网络
I want to use jQuery in my Bookmarklet. I included the source to my bookmarklet.js into the bookmarklet, so there is no more place for the jQuery File.

I want to use jQuery in my Bookmarklet. I included the source to my bookmarklet.js into the bookmarklet, so there is no more place for the jQuery File.

I've tried this to include jQuery inside the included bookmarklet.js

var s=document.createElement('script');
s.setAttribute('src','http://jquery.com/src/jquery开发者_如何学JAVA-latest.js');
document.getElementsByTagName('body')[0].appendChild(s);

But it doesn't work. What did I do wrong?


try adding one more attribute to specify the type of the source file:

s.setAttribute('type', 'text/javascript');
0

精彩评论

暂无评论...
验证码 换一张
取 消