试图在chrome扩展弹出窗口中获取textbox'name_textbox'的值到content_script.js
popup.js
document.addEventListener('DOMContentLoaded', docLoad , false);
function injectTheScript() {
textIn=document.getElementById('name_textbox');
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(tabs[0].id, {file: "content_script.js"});
});
}
function docLoad(){
document.getElementById('ok_btn').addEventListener('click', injectTheScript);
}
content_script.js
function clickPlanet() {
document.getElementById("register-email").value = textIn;
document.getElementById("register-confirm-email").value = textIn;
}
clickPlanet();