谷歌Chrome扩展消息传递与run_at document_start
Google Chrome Extension message passing with run_at document_start
我有一个关于消息传递(content_script.js发送请求和background.html发送响应)和JQuery $(document).ready()函数之间的执行控制的问题。
我在清单文件中设置了"run_at": "document_start",并根据文档。content_script.js将在CSS之后和任何脚本之前执行。在这种情况下,假设content_script.js改变了html页面的背景颜色,可以改变页面颜色的函数将在任何脚本之前被调用。
我的问题是关于content_script.js和background.html之间的消息传递。
如果我是正确的:例如事件
chrome.extension.sendRequest({storage: 'foo'}, function(response) {
runAfterResponseReceived();});
在content_script.js中定义,请求将在任何脚本运行之前发送到后台页面。一旦发送此请求,其他脚本就可以运行,而无需等待响应返回(解除阻塞)。因此,当响应返回时,content_script.js找到空闲时间,并执行函数runafterresponserreceived()。
然后,我如何将其更改为阻塞行为,以便我可以在返回响应后执行"任何脚本"。
我希望我已经解释了我的问题。谢谢。对不起,不可能。
相关文章:
- 正在寻找比$(document).ready慢的$(window).load的替代方案
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 如何用更合适的内容替换document.write
- document.styleSheets不返回任何内容
- jQuery document.ready not working
- $(document).height()在刷新时随机化值(Safari 5.1.10)
- reactjs this.refs vs document.getElementById
- 如何通过adf中的document.getElementById获取inputText字段值
- window.opener.document在ie中不起作用
- contentWindow.document.body is null
- document.applet.method在Mounatin Lion上抛出safari 6+JDK7异常
- @@(“at at”)在ES6 JavaScript中是什么意思
- document.getElementById(“st”).click();不起作用
- $(document).height和$(window).heaght都返回相同的值-使用的是正确的doctype
- jQuery document.ready停止代码
- document.getElementById并使用id名称
- 使用jQuery 1.8.1准备好多个$(document).是否有任何开销
- document.getElementById在js中不起作用
- Bootstrap javascript at very end and jQuery $(document).read