本文介绍了如何指定哪些内容脚本将在all_frames上运行,哪些不会?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在chrome扩展的清单文件中指定参数时,有一个选项 all_frames
。这允许将内容脚本嵌入到页面的所有框架中或不嵌入。
我想实现的一个例子是a.js以 all_frames = false 运行,b.js以 all_frames =真。 content_scripts
清单属性是一个数组 em>,因此您可以定义多个内容脚本规范对象:
content_scripts:[
pre>
{
matches:[http://www.google.com/*],
css:[mystyles.css],
js:[a.js ],
all_frames:false
},
{
matches:[http://www.yahoo.com/*] ,
js:[b.js],
all_frames:true
}
],
When specifying parameters in the manifest file of a chrome extension there is an option
all_frames
. This allows the content scripts to be embedded in all frames of a page or not.An example of what I want to achieve is have a.js running with all_frames=false and b.js with
all_frames=true
.解决方案The
content_scripts
manifest property is an array, so you can define multiple content script specification objects:"content_scripts": [ { "matches": ["http://www.google.com/*"], "css": ["mystyles.css"], "js": ["a.js"], "all_frames": false }, { "matches": ["http://www.yahoo.com/*"], "js": ["b.js"], "all_frames": true } ],
这篇关于如何指定哪些内容脚本将在all_frames上运行,哪些不会?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!