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
4 Answers
Reset to default 2I 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条)