Wednesday, September 07, 2005

Paul Graham for Print user script

I finally set down to write the Paul Graham for Print user script.
I was always annoyed by the formatting of his articles, which might make it easier to read on screen, but take a lot of space when printed.
This script hides the unrelated links and trailing empty lines from the article, and makes the text occupy 100% of the page width.

Enjoy.

Tuesday, September 06, 2005

IE bug with a label related to select

Here is a nice IE bug I just found.
When a <label> is attached to a <select> element, and the user clicks the label, the <select> is selected (which is nice), but its selectedIndex becomes 0 (that's not so nice).

Here is an example page.

Update: I found out that this is an MSDN report bug. See http://support.microsoft.com/default.aspx?scid=kb;en-us;314279&Product=iep. They also suggest a workaround - use the onfocusin event to store the current selection before the focus is actually moved to the list, and reset it later. However, they say "you can only work around this problem in Internet Explorer 6" - I'm not sure why, as the onfocusin event is said to be supported on Internet Explorer 5.5 and later.

However, I would suggest a much simpler solution - simply handling the label event ourselves, without IE to interrupt and destroy. In their sample, I would use:
<LABEL for="test" onclick="document.getElementById(this.htmlFor).focus(); return false;">Citizenship Status:</LABEL>

In my tests, it does the job perfectly well.