0
我正在使用Addon SDK。我很困惑如何將用戶輸入傳遞給我的插件index.js。我看了內容腳本,但它不完全是我所尋找的。當用戶點擊Addon按鈕時,我會彈出一個HTML頁面。下面是HTML代碼:如何將用戶輸入從HTML面板傳遞給Firefox中的Addon腳本Addon SDK
<html>
<head>
<style type="text/css" media="all">
textarea {
margin: 10px;
}
body {
background-color:white;
}
</style>
</head>
<body>
<form>
Enter name: <br>
<input type="text" id="txt-field">
<input type="submit" value="Add">
</form>
</body>
</html>
一旦用戶點擊HTML中add
按鈕,我需要通過用戶輸入的我main.js文件,然後我想永久保存它,除非用戶的文本手動刪除它。這裏是index.js:
var { ToggleButton } = require('sdk/ui/button/toggle');
var sdkPanels = require("sdk/panel");
var self = require("sdk/self");
var storage = require("sdk/simple-storage");
var button = ToggleButton({
id: "my-button",
label: "my button",
icon: {
"16": "./icon-16.png",
"32": "./icon-32.png",
"64": "./icon-64.png"
},
onChange: handleChange
});
var myPanel = sdkPanels.Panel({
contentURL: "./text-entry.html",
onHide: handleHide
});
function handleChange(state) {
if (state.checked) {
myPanel.show({
position: button
});
}
}
function handleHide() {
button.state('window', {checked: false});
}
你能指點我嗎我該怎麼做到這樣的事情?