我的Google扩展程序的代码如下:
window.addEventListener('DOMContentLoaded', function() {
chrome.tabs.query({
active: true,
currentWindow: true
}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {
from: 'popup',
subject: 'Import'
}, ShowResult);
});
});
function ShowResult(result) {
alert(result);
}
是否可以将此代码转换为jQuery?我不确定chrome.tabs.*
...
答案 0 :(得分:1)
尝试以下方法:
$(document).ready(function(){
chrome.tabs.query({
active: true,
currentWindow: true
}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {
from: 'popup',
subject: 'Import'
}, ShowResult);
});
});
function ShowResult(result) {
alert(result);
}