【发布时间】:2013-07-10 05:04:04
【问题描述】:
我创建了一个 JavaScript 变量,当我单击按钮时,它应该增加 1,但它没有发生。
这里是manifest.json。
{
"name":"Facebook",
"version":"1.0",
"description":"My Facebook Profile",
"manifest_version":2,
"browser_action":{
"default_icon":"google-plus-red-128.png",
"default_popup":"hello.html"
}
}
这是html页面的代码
<!DOCTYPE html>
<html>
<head>
<script>
var a=0;
function count()
{
a++;
document.getElementById("demo").innerHTML=a;
return a;
}
</script>
</head>
<body>
<p id="demo">=a</p>
<button type="button" onclick="count()">Count</button>
</body>
</html>
我希望扩展程序向我显示 a 的值,并在我每次单击扩展程序或按钮时将其加一
【问题讨论】:
-
你错过了开头
<script type="text/javascript"> -
@TimothyOnggowasito 那也是。 (我的回答)
-
@Neal 将其添加到您的答案中,以便更明显:)
-
@timothyonggowasito 在我点击扩展程序时仍然遇到同样的问题,它显示 =a 和计数按钮,当我点击计数按钮时它保持不变
-
@TimothyOnggowasito 花式时间:jsfiddle.net/maniator/ck5Yz/7 ^_^
标签: javascript google-chrome button google-chrome-extension content-security-policy