从浏览器外部调用Javascript函数?

发布于 2024-12-04 17:06:52 字数 190 浏览 0 评论 0原文

我有一个 Windows 托盘应用程序,需要与我的 Web 应用程序通信,特别是显示来电信息。

电话应用程序 (ProCall) 可以在接收到呼叫事件时启动应用程序。

我可以在新的浏览器窗口中打开特定的 URL,但理想情况下我想启动现有浏览器窗口的 Javascript 函数,然后使用 AJAX 来完成。

这可能吗?

I have a Windows tray application that needs to communicate with my web-application, especially displaying incoming call information.

The telephony-application (ProCall) can start applications when a call-event is received.

I could open a specific URL in a new browser window, but ideally I would like to start a Javascript function of an EXISTING browserwindow and then do it with AJAX.

Is this even possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

木槿暧夏七纪年 2024-12-11 17:06:52

您可以让您的应用程序通过 AJAX(通过轮询)或 COMET 与本地服务通信,并让托盘应用程序托管该服务或与该服务通信。这样,您就可以拥有从浏览器到托盘应用程序的非常简单的通信渠道。

否则,据我所知,您正在寻找类似 active x 控件的东西。

You could have your application talking to a local service via AJAX (with polling) or COMET and have the tray application either host that service or talk to that service. That way you could have a pretty easy channel of communication from your browser to the tray application.

Otherwise you're looking at something like an active x control as far as I know.

简单爱 2024-12-11 17:06:52

您可以在页面上插入

You can insert <script> tag on the page?
If yes you can put inside function call, or other code

风吹雪碎 2024-12-11 17:06:52

如果你可以改变javascript源,我想说你调用的url有额外的GET/查询字符串参数,或者散列,并且你的js解析它并采取相应的行动,

如果你想使用现有的窗口,你可能可以使用 COM 获取实例,并使用某种方法更改开放网站之一的哈希值,以将命令发送到 javascript,而无需重新加载。我很确定可以用 IE 甚至 FF 来做类似的事情。当然,您需要创建一个桌面应用程序来获取实例并调用其方法。我推荐 .net 或 .vbs 脚本

if you can change the javascript source, i'd say that the url you call have aditional GET/query string parameters, or a hash, and that your js parses it and act accordingly

if you want to use an existing window, you can probably get the instance using COM and with some method around change the hash of one of the open websites to send commands to javascript without reloading. i'm pretty sure it is possible to do something like that with IE, and probably with FF. of course, you need to create a desktop app that get the instances and call its methods. i'd recommend .net or a .vbs script

﹎☆浅夏丿初晴 2024-12-11 17:06:52

您希望两个浏览器窗口之间进行通信,但首先您必须从第一步开始:如何将一个浏览器窗口与另一个浏览器窗口关联起来?
为什么A应该联系B而不是C?

答案取决于这种关系。例如,如果 A 以某种方式导致 B 生成,则只需将“指针”传递给 B(可以简单地是会话 ID)即可。

You want communication between two browser windows, but first you must start from the first step: How will you relate a browser window to another one?
Why should A contact B not C?

The answer depends on this relationship. For example, if A is somehow causing B to spawn, it would be a matter of passing a "pointer" to B (which could simply be a session ID).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文