Sjoerd Visscher's weblog
Pondering those web technologies that may change the future of the world wide web.
Last Update
10/20/2005; 10:56:35 PM
Thursday, October 20, 2005
Leak Free Javascript Closures
If you're confused about how closures in JavaScript cause memory leaks in Internet Explorer, this is for you: Leak Free Javascript Closures. Then, without leakage, you can write code like this:
function attach() { var element = document.getElementById("my-element"); element.attachEvent("onclick", function() { alert("Clicked: " + this.innerHTML); }.closure(element)); }
Also if you want to do something like this: setTimeout(obj.method, 1000)
, and you find out that inside the method this
is not obj
, you can now do this: setTimeout(obj.method.closure(obj), 1000)
to fix it.
Sunday, August 14, 2005
No more accesskeys
I had accesskeys for the tabs at the top of this site, but Mark Wubben reminded me that this was very annoying, mainly because alt-d was one of them (the shortcut to focus the address bar). This makes me think that using accesskeys in webpages is not a very good idea, because you never know what the favorite shortcut keys of your visitor are.
How to use base URIs.
If you're wondering what a base URI is for, you'll always end up being directed to RFC 3986, but you won't find much. Section 5.1 just says: “The term "relative" implies that a "base URI" exists against which the relative reference is applied.”. But that there's more to it becomes apparent when same-document references come into play. One example is Tim Bray's atom feed. Here is part of it:
<feed xmlns='http://www.w3.org/2005/Atom' xml:base='http://www.tbray.org/ongoing/' xml:lang='en-us'> <title>ongoing</title> <link href='' />
As the base URI is already "http://www.tbray.org/ongoing/", the link to Tim's homepage can be the empty URI. However, according to RFC 3986, this is a same-document reference. It still references the correct URI, so usually you won't notice. But there are cases where this goes wrong, f.e. the XPath 2.0 expression fn:doc(/feed/link/@href)
will get you the current atom document, not the document at http://www.tbray.org/ongoing/. What's worse, you can't fix this by changing the link to <link href='http://www.tbray.org/ongoing/' />
, as the link is still the same as the base URI, so it still is a same-document reference.
So it seems you can't just use any base URI, but only the original URI of the content. Final proof comes from a discussion on the W3C URI mailing list. Here Roy T. Fielding, the author of RFC 3986, says: “[...] a person is deliberately abusing the base URI by assigning it an unrelated URI for the purpose of creating an artificial shorthand notation for external references.” Good to know!
I find it really odd that Roy calls something an abuse, which by most web developers is considered to be the only purpose of a base URI! And that he has added nothing to the new RFC 3986 to make this clear in any way. So we will have to do this ourselves. Spread the word: Stop the abuse of base URIs! I also hope Tim Bray will fix his atom file, as his feed is used as an example by many, so this abuse might spread to a lot of atom files.
[Update] Here's another example of base URI abuse in Atom.
To recap:
- Only use the actual URI of the document as its base URI, or the original URI if the document is moved. (This might actually be a good practice, with the same purpose as the self link in Atom.)
- If you use xml:base, add an xml:base attribute on content that is included from another document. (This happens automatically if you use XInclude.)
- Don't use the base URI for anything else.
Finally I'd like to share a trick to set the base URI for escaped HTML in RSS and Atom: add a BASE element to the beginning of the HTML content. This will work for most aggregators that run in a browser, like Bloglines, or use a browser component to display HTML, like most e-mail client based aggregators. Having multiple BASE elements in one HTML document, while not valid, works fine in most browsers. Aggregators can use this trick themselves as well.
Sunday, July 17, 2005
Atom 1.0 feed available
I've updated my Radio Userland Atom code to produce version 1.0. You can find the feed here. My RSS 0.91 feed is created with a simple XSLT transformation from the Atom feed.
Saturday, June 18, 2005
I live in Belgium
At least, that is what Google shows me, and Google is always right.
Wednesday, June 01, 2005
Being filmed by 3 cameras at once!
Sometimes it's really interesting to live in the centre of the administrative capital of the Netherlands. Today we had a referendum for ratification of the Treaty establishing a Constitution for Europe. I had to vote in the city hall. As this is close to the parliament buildings a lot of camera crews had chosen the city hall to film some voters, including me. So I ended up on Dutch national television. Here are some screenshots of that. There were more cameras than voters while I was there!
By the way, I voted in favor of the treaty, but it got rejected by a large majority.
Sunday, May 22, 2005
Musical Baton
Total volume of music files on my computer
Yahoo! Music Engine says “132 Songs, 9 hrs, 25 min, 03 sec, 553MB”.
The last CD I bought was
That's quite a while ago, I don't remember which one was last exactly. Let's say Kid A - Radiohead.
Song playing right now
Well, I was watching TV, but if I want to hear music I usually listen to my LAUNCHcast radio station, so I started that. I got A Stranger - A Perfect Circle, a very nice song that I had never heard before, which is exactly why I like LAUNCHcast so much.
Five songs I listen to a lot, or that mean a lot to me
There are no songs I listen to a lot, that would ruin them. I can't imagine how impressive Bohemian Rhapsody would have been if I could hear it now for the first time.
Five people I'm passing the baton to
There are five Q42 collegues who have weblogs (as far as I know): Laurens, Lukas, Chris, Anne (who passed me the baton) and (soon a colleage) Mark (already batoned).
Monday, May 16, 2005
About my name
If you let an english computerized narrator pronounce my first name, it sounds like sdzowurd, which is completely wrong. It's not really hard, the “sjoe” part sound just like shoe. The “r” should be a trilling r, but you hardly hear that. If you let the narrator say shoerd it sounds quite right.
Sjoerd is actually a Frisian name (not Dutch), but I have no roots there. My parents just liked the name. A while ago I found its etymology on this dutch site, it means victory guardian. Since then I use the name “Sigward” as nickname when playing games (which would be the Old German form of my name). Today I found names which mean the same and sort of sound the same too in other languages. In English there is Seward which is derived from Siward (from Macbeth). In Norwegian there is Sjurd which is derived from Sigurd, the name of two Norwegian kings.
My last name, you might have guessed, means (and sounds like) fisher (fisherman).