Christian Heilmann

You are currently browsing the Christian Heilmann blog archives for April, 2005.

Archive for April, 2005

Disabling Style Sheets via DOM

Thursday, April 14th, 2005

After a rather abysmal start of a three part article on DOM and CSS, Alejandro Gervasio came up with an interesting way to switch style sheets via DOM. I took the liberty to make the code a bit less obtrusive and checking for real DOM support.
It is not a real style switcher, and personally I consider JS only switchers pointless, but it is an interesting idea.

If Internet Explorer were a car

Tuesday, April 12th, 2005

I just wondered what it would be like if there were a car that behaved like
Internet Explorer.

  • You’ll find it one morning in your driveway, and there is no way of removing it.
  • The engine starts as soon as you approach it, which is a bit odd, but it seems to run smoothly enough not to pose a threat.
  • Everybody else seems to drive the same car, so you give it a spin.
  • It is pretty enjoyable to use – dead easy really. For example you don’t have to hit the gas pedal properly to accelerate, just putting your foot in the general surrounding is enough.
  • It does swerve a bit in the bends and newer roads are a really bumpy ride, but that is a minor problem, surely whoever builds these cars must be working on that.
  • For some reason, the roof leaks and when you ask others what can be done against that they advise you to wear a thick jacket made from a waterproof material. The best seems to be Symantex™.
  • There is plenty of parking space around the area, but somehow all parking lots have advertising signs blocking the way. You are advised to get a CowCatcherXP2™ to get rid of those.
  • After driving in some dark alleys a part of the windscreen shows advertisements for gambling arcades at random intervals. To get rid of those, you are advised to get a SpotwareRemoverTowel™. It takes some time and several attempts to get rid of the stains, but that is perfectly normal.
  • From time to time you get overtaken by faster cars playing classical music, and smooth moving ones (even on the newer roads) with foxtails on the rear-view mirror. They do look flash, but why bother? The drivers seem to be weirdoes.
  • On closer inspection, you see they attached things to their cars that make them a lot more comfortable to use. They tell you to get them in “extension shops” where the things are given away for free. When you ask for some, the shop tells you that you need to pay.
  • If you park the car in your garage and close the door to work on it you’ll get a message that you really should be on the road to make repairs.
  • If you try to change the colour of your car and fit nicer seats you realise that the paint never really covers all and the seats only fit when you fix them with a lot of adhesive tape. On the other hand it is really easy to change the colour of the tires and make the license plate fade in and out.

Communication spam

Thursday, April 7th, 2005

We would like to communicate with you!

The colossal experience of our predecessors, who made numerous complex
compositions of herbs, has found its embodiment in our various effective
phytotherapeutic methods of treatment of some internal and skin diseases.
Therefore we are looking for colleagues and also people who are interested
in what we do.

Were I to answer to that, the answer would be: “You failed to communicate”

Generating site navigation with PHP and DOM

Thursday, April 7th, 2005

I just finished EasyNav, a PHP script that automatically highlights the current page in a site navigation.

All you need to use it is generate your navigation as a nested list of links and include EasyNav in your pages. The current link gets automatically replaced with a “strong” element and gets the ID “current”. The parent list item gets the ID “active”.

This allows you to use the CSS examples of Listamatic to style your navigation.

EasyNav also allows for different navigations to be generated, dependent on the ID of the root UL.

MSIE DOM messing around with the name attribute

Monday, April 4th, 2005

I am working on a small editor for a CMS, and wanted to take a less WYSIWYG approach than for example HTMLarea does. My idea is to clone a node of possible block elements. Now, in the editor example Firefox works perfectly, the test output gets new IDs, for attributes and name attributes. MSIE however, fails to rename the name attribute (in the output the name of the textarea stays “c” instead of “c0”, the select doesn’t get a name attribute at all). The MSDN library does not have any information if there is a known bug.

The code in question:
ps[i].getElementsByTagName('label')[0].htmlFor='c'+i;
ps[i].getElementsByTagName('textarea')[0].id='c'+i;
ps[i].getElementsByTagName('textarea')[0].name='c'+i;
ps[i].getElementsByTagName('label')[1].htmlFor='t'+i;
ps[i].getElementsByTagName('select')[0].id='t'+i;
ps[i].getElementsByTagName('select')[0].name='t'+i;
Volkan Ozcelik pointed out on the evolt list that mixed case works:
ps[i].getElementsByTagName('label')[0].htmlFor='c'+i;
ps[i].getElementsByTagName('textarea')[0].id='c'+i;
ps[i].getElementsByTagName('textarea')[0].NAME='c'+i;
ps[i].getElementsByTagName('label')[1].htmlFor='t'+i;
ps[i].getElementsByTagName('select')[0].id='t'+i;
ps[i].getElementsByTagName('select')[0].NaMe='t'+i;

Anyone out there who can explain?