javascript - Communicating back to parent from a Webkit notification - Stack Overflow

I'm using webkitNotifications and createHTMLNotification, etc. to successfully create a notificati

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 municate 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...

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

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 municate 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./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

Share Improve this question asked Sep 7, 2010 at 7:10 jbobbinsjbobbins 1013 bronze badges 1
  • I'm trying to do the same thing. Did you find a solution? – Erdal Commented Oct 6, 2010 at 0:54
Add a ment  | 

4 Answers 4

Reset to default 2

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();}
notification.click= function() { alert('whatever'); };

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

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

I built Toobify. 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.

Short, Sweet, and Complete

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

  • SharedWorker + Desktop Notification Demo
  • SharedWorker + Desktop Notification Repo

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744791555a4593946.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信