【发布时间】:2023-03-18 22:27:01
【问题描述】:
如何获取由chrome.windows.create()创建的弹出窗口的window-id
background.html
window_options={
"url":"another_popup.html"
"type":"popup"
};
chrome.windows.create(window_options,call_back_function)
call_back_function(Window window)
{
console.log(window.id)
//prints the window's id properly
}
another_popup.html(弹出窗口所在的页面)
$(document).ready(function()
{
console.log(window.id)
//says ,cannot find property and gives a null
});
【问题讨论】:
-
您的问题是?.. 您的示例包含有关如何获取 ID 的信息。如果您出于某种原因在打开的页面中需要它,请通过
sendMessage或类似方法进行交流。 -
sendMessage 仅适用于内容脚本和背景页面之间的通信。在这里,它是一个来自后台页面的弹出窗口
标签: javascript html google-chrome google-chrome-extension google-chrome-app