Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将数据从chrome扩展传递到使用window.open打开的网页?_Javascript_Google Chrome_Google Chrome Extension - Fatal编程技术网

Javascript 如何将数据从chrome扩展传递到使用window.open打开的网页?

Javascript 如何将数据从chrome扩展传递到使用window.open打开的网页?,javascript,google-chrome,google-chrome-extension,Javascript,Google Chrome,Google Chrome Extension,我有一个chrome扩展,可以根据特定条件打开网页(新选项卡)。网页加载后,我需要将数据传递到新打开的窗口。如何操作?您不能使用window.open将数据从Chrome扩展传递到网页。向网页发送消息类似于。您的应用程序或扩展可以接收和响应来自常规网页的消息。在网页中,使用“runtime.sendMessage”或“runtime.connect”API向特定应用程序或扩展发送消息 您可以通过“runtime.onMessageExternal”或“runtime.onConnectExter

我有一个chrome扩展,可以根据特定条件打开网页(新选项卡)。网页加载后,我需要将数据传递到新打开的窗口。如何操作?

您不能使用window.open将数据从Chrome扩展传递到网页。向网页发送消息类似于。您的应用程序或扩展可以接收和响应来自常规网页的消息。在网页中,使用“runtime.sendMessage”或“runtime.connect”API向特定应用程序或扩展发送消息

您可以通过“runtime.onMessageExternal”或“runtime.onConnectExternal”API侦听来自网页的消息,。以下是一个例子:

chrome.runtime.onMessageExternal.addListener(
function(request, sender, sendResponse) {
if (sender.url == blacklistedWebsite)
return; // don't allow this web page access
if (request.openUrlInEditor)
openUrl(request.openUrlInEditor);
});

无法使用window.open将数据从Chrome扩展传递到网页。向网页发送消息类似于。您的应用程序或扩展可以接收和响应来自常规网页的消息。在网页中,使用“runtime.sendMessage”或“runtime.connect”API向特定应用程序或扩展发送消息

您可以通过“runtime.onMessageExternal”或“runtime.onConnectExternal”API侦听来自网页的消息,。以下是一个例子:

chrome.runtime.onMessageExternal.addListener(
function(request, sender, sendResponse) {
if (sender.url == blacklistedWebsite)
return; // don't allow this web page access
if (request.openUrlInEditor)
openUrl(request.openUrlInEditor);
});

不,似乎不可能