在Bookmarklet中包含JavaScript文件
我想在Bookmarklet中使用jQuery。我将bookmarklet.js的源代码包含在bookmarklet中,因此jQuery文件没有更多的位置 我尝试将jQuery包含在包含的bookmarklet.js中在Bookmarklet中包含JavaScript文件,javascript,bookmarklet,Javascript,Bookmarklet,我想在Bookmarklet中使用jQuery。我将bookmarklet.js的源代码包含在bookmarklet中,因此jQuery文件没有更多的位置 我尝试将jQuery包含在包含的bookmarklet.js中 var s=document.createElement('script'); s.setAttribute('src','http://jquery.com/src/jquery-latest.js'); document.getElementsByTagName('body'
var s=document.createElement('script');
s.setAttribute('src','http://jquery.com/src/jquery-latest.js');
document.getElementsByTagName('body')[0].appendChild(s);
但它不起作用。我做错了什么?尝试再添加一个属性以指定源文件的类型:
s.setAttribute('type', 'text/javascript');
不,那不行。我猜它不起作用,因为它是一个书签。当我使用jQueryify Bookmarklet列表添加jQuery时,效果很好,因此我的其余代码都正常工作。