【发布时间】:2015-03-14 14:06:52
【问题描述】:
我正在尝试通过我的 google chrome 扩展程序使用 content.js 脚本访问网页上的全局变量(计时器)。 然而,每次它返回未定义,即使我可以通过开发者控制台轻松访问它。
var mySocket;
console.log('content.js');
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
switch(request.task){
case "socketInjection":
window.setTimeout(
function(){ console.log(timer);}, 5000);
break;
}
});
我在那里使用 setTimeout 例程,以确保页面已完全加载(无论如何它应该已经加载)。
谁有解决方案? 在此先感谢丹尼尔
【问题讨论】:
标签: google-chrome google-chrome-extension