Monday, May 20, 2024
165
rated 0 times [  172] [ 7]  / answers: 1 / hits: 16048  / 12 Years ago, mon, april 30, 2012, 12:00:00

I am building desktop notification into my a chrome extension that I am working on. The functionality I need required that the user be taken to the tab that caused the notification when they click on the notification window. I can get that working using the chrome.tabs API, but what I can't manage to figure out is how to bring Chrome to the front when the notification is clicked.



I know window.focus() is disabled in chrome, but this is definitely possible to do since that's the behavior of the Gmail desktop notifications.


More From » google-chrome

 Answers
12
notification = webkitNotifications.createNotification(...)
notification.onclick = function(){
window.focus();
this.cancel();
};
notification.show()


...works as expected, without any additional permissions.


[#85878] Saturday, April 28, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dusty

Total Points: 739
Total Questions: 97
Total Answers: 85

Location: Angola
Member since Wed, Apr 13, 2022
2 Years ago
;