chrome.tabs在内容脚本中返回undefined [英] chrome.tabs returns undefined in content script
本文介绍了chrome.tabs在内容脚本中返回undefined的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
permissions:[
tabs,
http:// * / *,
https:// * / *
,
content_scripts:[
{
matches:[
http:// * / *,
https:// * / *
],
js:[
js / myScript.js
],
all_frames:true
}
],
$ c $ chrome.tabs
解决方案它自己的局限性,
chrome.tabs
只能在后台脚本和弹出脚本中使用。
如果您想要使用 chrome.tabs
,则将消息从content_script传递到后台脚本,并使用 chrome进行播放。标签
。
chrome.tabs returns undefined despite the fact I set tabs in the permissions block.
"permissions": [
"tabs",
"http://*/*",
"https://*/*"
],
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"js/myScript.js"
],
"all_frames": true
}
],
But in myScript.js the following returns undefined.
chrome.tabs
解决方案 As content script has its own limitations,
chrome.tabs
is only available in background scripts and popup scripts.
If you wanna to use chrome.tabs
then pass message from content_script to background script and play with chrome.tabs
.
这篇关于chrome.tabs在内容脚本中返回undefined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文