如果我有该选项卡的tabId,如何获取特定选项卡的窗口对象? [英] How do I get the window object for a specific tab if I have that tab's tabId?
本文介绍了如果我有该选项卡的tabId,如何获取特定选项卡的窗口对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有选项卡的tabId。如何获取它的窗口对象?
I have the tabId of a tab. How do I get it's window object?
推荐答案
要从tabId获取DOM窗口对象,您应该将内容脚本插入该标签:
To get the DOM window object from a tabId, you should insert a content script in that tab:
chrome.tabs.executeScript(tabId, {code:'var w = window; console.log(w);'});
https://developer.chrome.com/extensions/tabs#method-executeScript
也许你需要与你的背景页面交流:
Perhaps you'll need to comunicate with your background page:
https://developer.chrome。 com / extensions / content_scripts#主机页面通信
这篇关于如果我有该选项卡的tabId,如何获取特定选项卡的窗口对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文