manifest.json的它不能創建一個Chrome擴展
{
"name": "Summer",
"version": "1.0",
"manifest_version": 2,
"description": "This is an addition extension",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
}
}
popup.html
<!doctype html>
<html>
<head>
<title>Getting Started Extension's Popup</title>
<!-- JavaScript and HTML must be in separate files for security. -->
<script src="popup.js"></script>
</head>
<body>
<form name="form">
<div id="sayi1">Sayı 1 : <input type = "text" name="deger1"></div>
<div id="sayi2">Sayı 2 : <input type = "text" name="deger2"></div>
<div id="sonuc">Sonuç : <input type = "text" name="cevap"></div>
<div id="button"><input type="button" value="Hesapla" onclick="hesaplama()" /></div>
</form>
</body>
</html>
popup.js
function hesaplama()
{
var sayi1 = window.document.form.deger1.value;
var sayi2 = window.document.form.deger2.value;
var toplam = parseFloat(sayi1) + parseFloat(sayi2) ;
window.document.form.cevap.value = toplam;
}
後訪問popup.js文件
當我加載這個擴展,我可以正常看到。但是,當我填充deger1和deger2文本框,並單擊按鈕,函數不起作用,在sonuc文本框(結果文本框)爲空。 我該如何解決它?我是創建Chrome擴展的新手。謝謝你的幫助。
'eval'的濫用?使用'parseFloat(說\ u01311)+ parseFloat(說\ u01312)'而不是... – 2012-04-11 12:39:49
它不能再工作 – cethint 2012-04-11 12:46:39
您是否在控制檯中發生任何錯誤? https://code.google.com/chrome/extensions/tut_debugging.html#inspect-popup – abraham 2012-04-11 18:11:16