Tuesday, November 9, 2010

Making More Natural Desktop Notifications in Chrome

Do you have a website or application that uses Google Chrome Desktop Notifications? 
Well, let me just share with you this very simple snippit of code that will make their interaction a lot
more natural.
[codesyntax lang=xml]<!DOCTYPE html>

<meta charset="utf-8">
html * { font-family:
sans-serif; }
h1 { padding: 0; margin: 0; font-size: 12pt; font-weight: bold; }
body {
font-size: 10pt; }
changeLinks() { for(var i = 0;i < document.getElementsByTagName("a").length;i++) { ele =
document.getElementsByTagName("a")[i]; ele.target = "_blank"; } }
function detectClick(e) { var
rightclick; if (!e) { var e = window.event; } if (e.which) { rightclick = (e.which == 3); } else if
(e.button) { rightclick = (e.button == 2); } if (rightclick) { self.close(); } }
onload="document.timeout = setTimeout(self.close,5000);changeLinks();"
onmouseover="clearTimeout(document.timeout);" onmouseout="document.timeout = setTimeout(self.close,5000);"
onclick="self.close();" href="/link/" target="_blank">


really all there is to it. Lives on a 5 second time. If you hover over it, it stays longer, if you right
click it it closes. If you click it it goes to /link/. Quite nifty, if I do say so myself.

slightly buggy regarding links in the message.. but meh.

No comments:

Post a Comment