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
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 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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With