通过 Webkit 通知与家长进行沟通
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我知道这个问题很旧,但这是我用来将焦点返回到创建通知的窗口/选项卡的方法:
I know this question is old, but here's what I'm using to return focus to the window/tab that created a notification:
对我有用,但当然它很丑......
Works for me, but of course it's ugly...
有一种解决方案可以使用 共享 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.
简短,甜蜜,完整
这花了我几个小时,但我有一个基本的例子:
请原谅自述文件的简短,现在是凌晨 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.