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.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> html * { font-family: sans-serif; } h1 { padding: 0; margin: 0; font-size: 12pt; font-weight: bold; } body { font-size: 10pt; } </style> <script> function 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(); } } </script> </head> <body onload="document.timeout = setTimeout(self.close,5000);changeLinks();" onmouseover="clearTimeout(document.timeout);" onmouseout="document.timeout = setTimeout(self.close,5000);" onmouseup="detectClick();"> <a style="display:block;cursor:normal;padding:0;margin:0;color:black;text-decoration:none;" onclick="self.close();" href="/link/" target="_blank"> <h1>Title</h1> <span>Message</span> </a> </body></html>
Thats 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.
Its slightly buggy regarding links in the message.. but meh.
Making Google Analytics Work in XHTML
I was moving my website, Google Voice for Outlook, over from HTML5 to XHTML5 today, and as soon as I did the basic content negotiation filters in PHP so that it would send the appropriate headers if the client supported XHTML as well as only outputting the <?xml if the client supported XHTML, I checked my developer tools to find a JavaScript error. It was Google Analytics, of course. document.write doesn’t exist in XHTML, after all.
The fix was simple, replace the current four line inclusion code with:
<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); var script = document.createElement("script"); script.src = gaJsHost + "google-analytics.com/ga.js"; script.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(script); </script>
This will work fine, unless of course you have no head tag. In which case you should replace getElementsByTagName(“head”) with getElementsByTagName(“html”).
HTML5 Being a Pain in My Ass Again
This time in regards to the highly acclaimed and very well received <video> element.
On my website, Google Voice for Outlook I use the <video> tag to show a demonstration of the system working. I don’t currently have a way to encode in ogg, and/or am too lazy too, so I decided that if the web browser didn’t support h264 video, it’d fall back to the YouTube video. The expected result (from me, of course) was that if it can’t display the video, it’d display the YouTube. Apparently though, in FireFox it does not fall back to the YouTube video and instead just displays a gray box, and the fault this time doesn’t lie with FireFox, but with the standard:
Content may be provided inside the video element. User agents should not show this content to the user; it is intended for older Web browsers which do not support video, so that legacy video plugins can be tried, or to show text to the users of these older browsers informing them of how to access the video contents.
Ugh! This means that if you want to use <video> on any website, ever, properly, you’re going to have to encode it in both h264 and Theora until the industry decides on a set standard.
Purely Atrocious.
Why HTML should become a dead language
Go ahead, take a gander around the Internet. Lets see who is using HTML, and who is using XHTML.
- XHTML
- Blogger [Served as HTML]
- Opera [Served as XML]
- FireFox (Mozilla) [Served as HTML]
- Facebook [Served as HTML]
- MySpace [Served as HTML]
- Twitter [Served as HTML]
- W3C [Served as HTML]
- HTML
- Microsoft
- Yahoo!
- Apple
- WHATWG
As you can see, the "newer" websites are serving in XHTML. A few of them Transitional (mainly websites where users can input HTML), however, a large number of them are marked as XHTML 1.0 Strict using the W3C DTD.
On to my main point, HTML should NOT receive an update. The primary reason people want it to, is because it is FAMILIAR to designers and developers. However, HTML is very lax on how it is interpreted, a little too lax in my personal opinion.
An Example. <input type="text" disabled>. The tag does not end. Its interpreted as a single tag, and disabled means that its disabled. I, myself, find this to be horrible, horrible code. In XHTML, all tags must end, and all properties must have a value. Which is easier to program, an HTML or an XHTML parser?
Probably the XHTML. HTML was not designed to be parsed, and is really quite a pain to attempt to parse using such things like Regex, considering how lax of a language it is.
In my own personal opinion, HTML should become a dead language. Some people hold on to it, let them. Let them continue making their websites in Archaic HTML 4. But do we really need to run an update to it? No. We should, move to XHTML. XML has already proven to be a very dependable language. Its used in such popular applications like Jabber, and Twitter, and is used commonly with AJAX, which is the height of the "Web 2.0" Revolution.
So why are we trying to revise it? Why can't we adopt a stricter set of rules so that they can better be implemented? In my personal opinion, work on HTML should be halted, and moved to XHTML. I still believe that the W3C and WHATWG should work together on a new version of XHTML. XMLEvents and XForms should adopt the magnificent features that Web Forms 2.0 has created. Again, this is my personal opinion.
EDIT: Added What Some sites are served as. Its actually pretty depressing.
XHTML2 vs. HTML5
What the hell is up with this fanboy war? The web design community has already started getting used to XHTML, but now the WHATWG group wants the continued update of HTML? Isn't that a step backwards?
HTML was wild, unordered, and controlled by the browser vendors (at least from what I've seen), however, XHTML was started and controlled by the W3C group, making sure that it gets properly implemented, however, the WHATWG group doesn't like it. They want to stay with their old fashioned <b> tags.
I admit, web designers from the 90s have gotten used to the old style HTML tags, and its still what they're teaching in school, but that is no reason to stay with it. Technology changes over time, this is the same for any tech profession, the data will change, and then you'll have to learn something new. This isn't just the case for tech jobs, but jobs that use computers. Microsoft publishes a new Operating System, your company updates, and you need to re-learn it.
XHTML1 supports backwards compatibility with HTML for the old authors who are still getting used to it, and so that browsers can still render old code, XHTML2 doesn't, but all browsers should properly implement both. But by creating HTML5 and "XHTML5", WHATWG is requiring browser vendors to include yet another set of standards into browsers in order to properly display the internet.
Personally, I have yet to find a website that uses HTML5. Most websites have already started using XHTML, and so I truly believe that implementing a new version of HTML is a step backwards.
If the WHATWG group wants to continue their efforts (like their wonderful work with Web Forms 2.0), I think their best bet would be to join the W3C's work with CSS and XML Events, and XForms, don't you? If the two worked together, instead of fighting about such silly things, then maybe standards could be developed a lot faster, after all, the W3C does seem to be taking a long time to update and recommend standards. Lets get things done faster, I want to start using XHTML2 and CSS3 already :-p