【发布时间】:2014-04-27 20:53:25
【问题描述】:
$(document).ready(...) 中的脚本不起作用,有什么想法吗?
我尝试注入的脚本似乎最终加载了。
这是我的代码:
main.js
pageMod.PageMod({
include: "*",
contentScriptWhen: 'start',
contentScriptFile: data.url('inject.js')
});
注入.js
var script = document.createElement('script');
script.src = "resource://directoryOfMyAddon/data/jquery/jquery-1.11.0.min.js";
document.getElementsByTagName('head')[0].appendChild(script);
test.html
<html>
<head>
</head>
<body>
<div id="helloworld"></div>
<script type="text/javascript">
$(document).ready(function(){
$("#helloworld").text("Hello, world!");
});
</script>
</body>
</html>
谢谢 O=)
【问题讨论】:
标签: javascript jquery firefox-addon firefox-addon-sdk