使用Chrome扩展程序在网页和本机应用程序之间进行通信时出错(Error in communication between Webpages & native application using C

系统教程 行业动态 更新时间:2024-06-14 16:57:39
使用Chrome扩展程序在网页和本机应用程序之间进行通信时出错(Error in communication between Webpages & native application using Chrome Extension)

我正在开发一个使用扩展来与本机应用程序通信的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.

更多推荐

本文发布于:2023-04-13 11:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/5443dbe6cb960e5cc4e016687d7564dc.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:本机   应用程序   通信   网页   程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!