我正在开发一个使用扩展来与本机应用程序通信的Web应用程序。
但我在chrome.extension.connectNative上未定义,而简单连接可用。
对于相同的扩展程序代码,如果我将其设为“Chrome应用程序”,并从扩展程序中的页面进行连接,则可以正常使用。
请帮我解决这个问题。
这是一个图表形式,(XXX)指的是我面临问题的区域。
我的网络应用程序 - > javascript - > Chrome扩展程序(XXX) - >本机主机
我已经检查了我的扩展程序所需的所有权限,正如我所提到的,如果我运行扩展程序独立运行它。
我正在重用原始示例中提供的代码: http : //src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/nativeMessaging/
I am developing a web application that uses an extension to communicate with native application.
But I am getting undefined on chrome.extension.connectNative whereas simple connect is available.
For the same extension code, if i make it a "Chrome App", and connect from a page within the extension it is working fine.
Please help me with this issue.
Here is a diagrammatic form, (XXX) refers to the area where I am facing the problem.
My Web App --> javascript --> Chrome Extension (XXX)--> Native Host
I have check all the required permissions for my extension, and as I mentioned it works if I run the extension standalone.
I am reusing the code provided in original example: http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/nativeMessaging/
最满意答案
大多数chrome。* API在普通的网页上下文中不可用。 如果您想在页面中使用这些API,则需要将消息发送到您的扩展程序的背景或事件页面 。
Most chrome.* APIs are unavailable in a normal web-page context. If you want to use those APIs in your page, you'll want to send messages to your extension's background or event pages.
更多推荐
发布评论