我正在使用扩展谷歌浏览器,我使用以下popup.html文件运行一个简单的扩展程序:
<script type = "text/javascript">
alert("hi from popup.html");
</script>
<body>
Hello World
</body>
只要我将带有url的src属性添加到google jquery CDN'alert(“来自popup.html”);'不再运行了。
我的清单文件如下:
{
"name": "My First Extension",
"version": "1.0",
"description": "The first extension that I made.",
"background_page": "background.html",
"browser_action": {
"default_icon": "icon.png",
"popup": "popup.html"
},
"permissions": [
"tabs","http://*/*","https://*/*"
]
}
为什么添加jquery源会破坏弹出窗口?
答案 0 :(得分:5)
您需要将脚本分成两个语句。试试这个:
<script type="text/javascript" src="jQuery.js"></script>
<script type="text/javascript">
alert("hi from popup.html");
</script>