Archive for December 2008
Us
In Thud, the dwarf Bashfullsson says “I need no axe to be a dwarf, Nor do I need to hate trolls. What kind of creature defines itself by hatred?”.
Don’t we?
Peeling the covers off HTML5
Went back to the HTML5 draft spec after a long while and found some interesting tidbits as usual.
element.click() has been made non-reentrant :- no worries anymore about dumb users clicking buttons again and again.
src attribute in img will be ignored if its the same as the page url :- most browsers used to fire an HTTP request even if the src attribute pointed to the same url as the page url (formally known as the ignored self-reference), duh.
And here’s the beast of a change which introduces script groups. Takes a while to stomach the implications.
MY NEW YEAR RESOLUTION :: MUST.KEEP.REVISITING.HTML5.SPEC.
event.returnValue
You won’t know how important this sucker is unless you’ve coded confirmation dialogs in IE7. Yes, those worthless pop-ups which are supposed to help out the clueless.
<husky_mocking_overbearing_voice>
You might want to save you changes before you go to the other link! Are you sure you want to navigate away? Were all those clicks really just fluff not to be recorded for posterity?
</husky_mocking_overbearing_voice>
I was merrily invoking a js function from an anchor which throws up a innocuous confirmation dialog when I realized that clicking Cancel was still posting the page to the href URL!
Here are the relevant bits:-
<a onClick="javascript:return processClick(event);" href="/takemeaway">Click me</a>
function processClick(event) {
if (unsavedChangesOnPage) {
return showDialog(event);
}
}
function showDialog(event) {
return confirm("Do you really want to lose your changes?");
}
Apparently, with confirmation dialogs sometimes (on some machines; come on I should have a better answer); IE forgets to set the event returnValue to false! Bloody piece of crap!
Anyway, the solution was merely setting event.returnValue explicitly to false if Cancel was clicked.
Here’s the fix:-
function processClick(event) {
if (unsavedChangesOnPage) {
var result = showDialog(event);
if (!result && itsStupidIE()) {
event.returnValue = false;
}
return result;
}
}
No love lost between me and IE!
Not now; not ever.
Antikythera
Finally..see the working version here.
Corroded remains of the device were found a century ago by spongedivers, who happened upon the shipwreck of a roman merchant vessel while sheltering from a storm near the island of Antikythera.