如何用javascript发送真正的咆哮消息?

发布于 2024-08-06 00:32:02 字数 129 浏览 11 评论 0 原文

是否可以使用 JavaScript 从 Web 应用程序向用户的计算机发布咆哮通知?这仅适用于 Intranet 应用程序,因此安全性不是主要问题。此外,它仅限于使用 Safari 或 Firefox 的 Mac 用户。

谢谢。

Is it possible to post growl notifications to a user's computer, from a web application, using javascript? This will be only on an intranet application so security is not a major concern. Additionally it will be limited to only Mac users with Safari or Firefox.

Thanks.

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

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

发布评论

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

评论(9

音盲 2024-08-13 00:32:02

Growl 有一个 网络接口,而 HTML 5 有 Web Sockets,因此理论上完全可以在 JavaScript 中实现(当实现 Web Sockets 时)。更现实的是,如果您的网络服务器与您的客户端连接到同一网络(即可以查看并连接到它们各自的 IP 地址),您可以对服务器上发出网络请求的脚本执行 AJAX 样式回调。

Growl has a network interface, and HTML 5 has Web Sockets, so in theory it might be possible entirely in JavaScript (when Web Sockets are implemented). More realistically, if your webserver is connected to the same network as your clients (i.e. can see and connect to their individual IP addresses), you could do an AJAX style callback to a script on the server that will make the network request.

街道布景 2024-08-13 00:32:02

Fluid,Mac 的特定于站点的浏览器生成器,公开 JavaScript Growl 通知 API [< a href="http://fluidapp.com/developer/" rel="nofollow">1]:

window.fluid.showGrowlNotification({
    title: "title", 
    description: "description", 
    priority: 1, 
    sticky: false,
    identifier: "foo",
    onclick: callbackFunc,
    icon: imgEl // or URL string
})

相关来源为 在 Fluid 开发者页面

您可以在 userscripts.org

当然,这种方法的一个缺点是,您必须强制用户在访问 Intranet 应用程序时使用 Fluid 浏览器。

像 Adam 建议的那样建立桥梁的优点是需要用户付出最少的努力。

Fluid, a site-specific browser generator for Mac, exposes a JavaScript Growl notification API [1]:

window.fluid.showGrowlNotification({
    title: "title", 
    description: "description", 
    priority: 1, 
    sticky: false,
    identifier: "foo",
    onclick: callbackFunc,
    icon: imgEl // or URL string
})

Relevant source is on the Fluid Developer page.

You can search for real-world examples at userscripts.org.

One downside with this approach is, of course, you have to force your users to use a Fluid browser when accessing the intranet application.

Setting up a bridge like Adam suggests has the advantage of requiring minimum effort from the users.

夜吻♂芭芘 2024-08-13 00:32:02

我试图想出一个用 javascript 发送咆哮消息的解决方案,但遗憾的是没有运气。我将总结我的研究以供将来参考。

研究了可能的解决方案:

  • Flash - 由于 flash 可以访问常规套接字连接,因此提出一个 flash 代码片段似乎是一个好主意,该代码片段可以通过ExternalInterface 向 javascript 公开一些 API。 Flash 对象将从网站服务器(远程位置)提供服务,并尝试与本地咆哮接口进行通信,这将触发检查跨域策略文件。这涉及到咆哮服务目前无法理解(支持)的通信,因此连接会失败。 作为额外信息:Windows 版的咆哮支持基于 Flash 的客户端,但从这个 最近的讨论在当前版本中已损坏)。

  • WebSockets - 与基于闪存的想法类似,websockets 需要初始交换几个 http 请求/响应在连接升级为常规双向套接字连接之前。与 Flash 方法一样,这可以工作,但需要在套接字连接之前咆哮来支持基于初始 http 的通信。 Growl 目前不支持这一点,有人说一旦 Growl 的规范最终确定,它可能会支持。

  • Google Gears - 尚未测试过,但google gears 已于 2011 年 3 月停产,可能会在支持版本 >= 4 的 Firefox 时出现问题。

I tried to come up with a solution for sending growl message with javascript, with no luck, sadly. I'll summarize my research for future reference.

Possible solutions investigated:

  • Flash - due to flash having access to regular socket connections it seemed like a good idea to come up with a flash snippet that would expose some API to javascript via ExternalInterface. Flash object would be served from website server (remote location) and try to communicate to local growl interface, that would trigger checking cross-domain policy file. That involves communication that isn't understood (supported) by growl service for now, so connection would fail. As an extra info: growl for windows had support for flash based clients but judging from this recent discussion its broken in current version).

  • WebSockets - similar to flash-based idea, websockets require initial exchanging couple of http requests/responses before the connection is upgraded to regular two-way socket connection. As in Flash approach, that would work, but require growl to support that initial http based communication prior to socket connection. Growl doesn't support that for now, some say it might, once the specification for growl is final.

  • Google Gears - Haven't tested it, but google gears has been discontinued as of march 2011, probably raising issues with supporting Firefox in version >= 4.

眉黛浅 2024-08-13 00:32:02

帖子 http://ajaxian.com/archives/growls -for-windows-and-a-web-notification-api 包含一个growl.js 的链接,该链接是为与Windows 版Growl 一起使用而编写的。我还没有进行足够的研究,不知道类似的方法是否适用于 Growl。

The post http://ajaxian.com/archives/growls-for-windows-and-a-web-notification-api contains a link to a growl.js which was written to work with Growl for Windows. I haven't looked into it enough to know whether a similar approach would work with Growl.

-残月青衣踏尘吟 2024-08-13 00:32:02

对于仅限客户端的方法,我尝试了以下方法:

如果使用 Growl for Windows 或 Growl 版本 1.3+,
您可以使用 Flash 二进制文件,如此演示页面中所示,

还有一个 chrome-extension由 GfW 制作,本身使用二进制文件作为 NPAPI。 GrowlChrome
它们基于由 GfW 开发的 GNTP 协议,最初的 Growl(适用于 Mac)预计从 1.3 版本开始采用它。

对于 1.2.x 版本,我发现了另一个有效的 chrome 扩展:Twitter NotifierGoogle Play 的 Growl Notifier 。这些扩展程序基于 JSGrowl

链接

  • GoogleChrome
  • Twitter 通知程序
  • < a href="http://chrome.google.com/webstore/detail/ojfooeehijnknikclfimbcekmncgabmp" rel="nofollow">适用于 Google Play 的 Growl 通知程序

For client-only methods, I've tried the following:

If using Growl for Windows or Growl version 1.3+,
you can use the Flash binary as illustrated in this demo page

There also is a chrome-extension made by GfW that uses the binary as NPAPI natively. GrowlChrome
These are based on GNTP protocol which was developed by GfW, and the original Growl (for Mac) projected adopted it from version 1.3

For version 1.2.x, I found another chrome-extension that works: Twitter Notifier and Growl Notifier for Google Play . These extensions are based on JSGrowl

Links

浅笑轻吟梦一曲 2024-08-13 00:32:02

您还可以尝试 Gritter,“jQuery 的类似咆哮的通知”。

You could also try Gritter, "a growl-like notification for jQuery."

蝶…霜飞 2024-08-13 00:32:02

另一位发帖者提到了这一点,但您绝对可以使用 Javascript(借助 Flash 的一小部分,但您不必弄乱该部分)向本地运行的 Growl 发送通知。这是一个测试页面,无需进行任何设置即可尝试:http://www.growlforwindows。 com/gfw/examples/js/

但请注意,这当前仅适用于 Windows。正如之前的海报所指出的,Mac 版本对基于 Flash 的连接的支持目前已被破坏。

在 Windows 上,您还可以使用 WebSockets,这里是一个类似的测试页面: http://www .growlforwindows.com/gfw/examples/websocket/

请注意,Mac 上的 Growl 目前也未实现此功能,因此,如果您的目标是 Mac 用户(听起来像您),这些可能没有帮助。只是想指出,一旦 OSX 客户端完全添加支持,Javascript 和 WebSocket 都是可能的。

Another poster mentioned it, but you definitely can use Javascript (with a small helping of Flash, but you dont have to mess with that part) to send notifications to Growl running locally. Here is a test page to try it out without setting anything up: http://www.growlforwindows.com/gfw/examples/js/

Note however, this only currently works on Windows. As an earlier poster noted, the Mac version's support for Flash-based connections is currently broken.

On Windows, you can also use WebSockets, and here is a similar test page: http://www.growlforwindows.com/gfw/examples/websocket/

Note that this too is currently not implemented in Growl on the Mac, so if you are targeting Mac users (which it sounds like you are), these probably dont help. Just wanted to point out that both Javascript and WebSockets are possibilities once the support is fully added to the OSX client.

一杯敬自由 2024-08-13 00:32:02

如果您的用户有 Flash,您可以从此处借用 javascript-flash-growl 桥。您始终可以使用 JPEXS 之类的工具检查闪存内部的脚本。

我个人已经成功地使用它和 jQuery 为自己设置了一些自定义通知 使用 mediawiki< /a> 并使用 tampermonkey/greasemonkey。如果闪存被阻止/不允许/未安装,或者闪存崩溃,则会出现唯一的问题。

If your users have flash, you can borrow the javascript-flash-growl bridge from here. You can always check the script insides of the flash with something like JPEXS.

I've personally successfully used it and jQuery to setup some custom notifications for myself using mediawiki and using tampermonkey/greasemonkey. The only issues come if flash is blocked/disallowed/not installed, or when flash crashes.

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