Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Bookmarklet中包含JavaScript文件_Javascript_Bookmarklet - Fatal编程技术网

在Bookmarklet中包含JavaScript文件

在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'

我想在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')[0].appendChild(s);

但它不起作用。我做错了什么?

尝试再添加一个属性以指定源文件的类型:

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

不,那不行。我猜它不起作用,因为它是一个书签。当我使用jQueryify Bookmarklet列表添加jQuery时,效果很好,因此我的其余代码都正常工作。