我正在寫我的第一個Chrome擴展,它具有以下功能。當用戶右鍵單擊圖像並在上下文菜單中選擇適當的字段時,會創建一個包含表單的彈出窗口。從上下文菜單中調用以下函數。如何通過javascript在Google Chrome上通過html表單提交用戶提交的值?
function new_window(){chrome.windows.create({
url: "reddit.html",
type: "popup",
focused: true,
width: 200,
height:140})
的其中包含「reddit.html」內部格式如下:
<form id="post_on_forum" method="get">
<input type="text" name="title" placeholder ="title"><br>
<input type ="text" name="Category"placeholder ="Category" ></br>
<input type="submit" value="Submit" id="submit">
</form>
我的問題是:如何使用JavaScript獲取用戶輸入的每次他提出什麼變量?我無法使用內嵌JavaScript,因爲Chrome禁止這樣做。我創建了submit.js
這是
$(document).ready(function() {
$('#Submit').on('click',(function() {
foo($('#post_on_forum').val());
}));
console.log("triggered");
});
但它不起作用。當然,我已經在清單文件中包含了所有適當的文件。
你在控制檯得到一個錯誤序列化表單輸入? – davy
none我沒有得到任何東西 – user1608778