通过 Webkit 通知与家长进行沟通

发布于 2024-09-18 08:54:15 字数 542 浏览 3 评论 0原文

我正在使用 webkitNotifications 和 createHTMLNotification 等在 Chrome (Windows) 中成功创建通知。

现在我真的很想让通知窗口与创建通知的选项卡/窗口(或至少将焦点设置到)进行通信(这是规范的一部分)。我意识到此功能仍处于早期阶段,但我想也许有人知道一种方法。我尝试过:

window.opener.focus();

从通知窗口,但它不起作用。

此页... http://www.thecssninja.com/javascript/web-notifications

说... “如提案中所述,通过使用 window.opener.focus() 将焦点带回到调用通知的窗口,当前不起作用。”

我希望它要么已经过时,要么有人知道解决方法。

感谢您可以分享的任何信息。

吉姆

I'm using webkitNotifications and createHTMLNotification, etc. to successfully create a notification in Chrome (Windows).

Now I would really like to have the notification window communicate back (or at least set the focus to) the tab/window that created the notification (which is part of the spec). I realize it's still in the early phases for this feature, but I thought maybe someone knows a way. I tried:

window.opener.focus();

from the notification window, but it didn't work.

This page...
http://www.thecssninja.com/javascript/web-notifications

says...
"Bringing focus back to the window that called the notification, as stated in the proposal by using window.opener.focus(), doesn’t currently work."

I was hoping it was either out of date or that someone might know a workaround.

Thanks for any information you can share.

Jim

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

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

发布评论

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

评论(4

何时共饮酒 2024-09-25 08:54:15

我知道这个问题很旧,但这是我用来将焦点返回到创建通知的窗口/选项卡的方法:

notification.onclick = function() {window.focus(); this.cancel();}

I know this question is old, but here's what I'm using to return focus to the window/tab that created a notification:

notification.onclick = function() {window.focus(); this.cancel();}
硬不硬你别怂 2024-09-25 08:54:15
notification.click= function() { alert('whatever'); };

对我有用,但当然它很丑......

notification.click= function() { alert('whatever'); };

Works for me, but of course it's ugly...

恏ㄋ傷疤忘ㄋ疼 2024-09-25 08:54:15

有一种解决方案可以使用 共享 webworkers< 在窗口之间进行通信/a>.

我使用“远程”按钮构建了 Toobify.com,这是一个控制父窗口的 webkitNotification 窗口。如果您有勇气的话,请查看该项目的源代码。

我还想将焦点设置为返回到此窗口。似乎是基于文本的通知的功能,而不是 HTML 类型的功能。

There is a solution to communicate between windows using shared webworkers.

I built Toobify.com with a "remote" button, a webkitNotification window that controls the parent. Have a look at the source of the project - if your feeling brave.

I'd also like to set focus to go back to this window. Seems to be a feature of the textbased notification not the HTML kind.

谈下烟灰 2024-09-25 08:54:15

简短,甜蜜,完整

这花了我几个小时,但我有一个基本的例子:

请原谅自述文件的简短,现在是凌晨 3:30,我正在冲刺。

问我问题,我会回答并清理文档。

Short, Sweet, and Complete

It took me several hours, but I've got a basic example:

You'll have to excuse the brevity of the README, it's 3:30am and I was sprinting.

Ask me questions and I'll answer them and clean up the docs.

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