I'm working on a fork of an online Twitter client. (Streamie, if you're interested.) I'd like to improve the Chrome notifications by using HTML notifications instead of the static ones it uses now.
The problem is that I need to get the tweet object from the main page to the notification, and I'm not sure how to do this. In my Chrome extension I got around this by making an array with a queue of tweets to show, adding a function to the window object which returned queue.shift() and then calling that function via chrome.extension.getBackgroundPage().dequeueMsg();
.
However, I obviously don't have this option in a web client. Is there any way to communicate from a notification with the window that opened it, or from the page to the notifica开发者_JAVA百科tion's DOM?
Well from the spec:
Within a web notification, the
window.opener
property should be set to the window which created the notification. If the notification was created by a worker script,window.opener
should benull
.
It looks like code in the notification page can access window.opener
just like a page created with window.open()
can. (Now, as to the practical aspect of doing this with today's actual browsers, that's another thing I guess.)
精彩评论