我有代码背景js:
chrome.contextMenus.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null, {
code: "setInterval(function(){alert('test')}, 2000)"
});
});
var id = chrome.contextMenus.create({
"title": "Auto Refresh",
"contexts": ["page"]
});
它工作,每 2 秒它有一个警告框“测试”;
但是我用 location.reload 替换了 alert('test'):
chrome.contextMenus.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null, {
code: "setInterval(function(){location.reload()}, 2000)"
});
});
var id = chrome.contextMenus.create({
"title": "Auto Refresh",
"contexts": ["page"]
});
第一次只有1次刷新,不会继续刷新。请帮助我,谢谢