16 Mar

ie6 bug – regexps, split, and carriage returns

This one had me stumped for half an hour… In my AJAX shopping cart, I return a file which is delimited by carriage returns. Some of the lines of the file may be blank. On the client side, I then split that into an array. Firefox was giving me the correct array, but IE6 was dropping all the blank lines.

It took me a while, but I finally figured it out. It seems that if you split using the method file.split(/\n/), then IE6 rips up that regexp and replaces it with file.split(/\n+/).

Here is some sample code – this works perfectly in Firefox, but the problem is demonstrated in the first three alerts for IE6.


As you can see, the solution is to split on the string '\n' instead of the regexp /\n/, although that obviously is not ideal in all cases.

As usual, we web developers can thank Microsoft for the hell that we go through.

16 Mar

addRule bug in IE6

If you use the addRule() function in IE6 to add a style element, then be aware that IE6 does not seem to understand the usage of commas in selectors. It will return an “invalid argument” error.

In CSS, the comma in a selector is used to say “the following styles apply to each of these comma-delimited items”. So, for example. a,h1{text-decoration:underline} should underline anchors and header-ones.

Here is a function to add rules for both IE and Firefox. It took me fifteen minutes of debugging to figure out the comma bug, but that’s fixed in the below code.

function addRule(rule){
  var a=document.styleSheets[0],arr=rule.replace(/}.*/,'').split('{'),arr2,i;
  else if(a.addRule){

The above is called like this: addRule('a,h1{text-decoration:underline}'); in JavaScript. At the moment, it requires that a stylesheet be attached, but that requirement can easily be hacked away.

06 Mar

why .net, c# and mono are bad names

from slashdot

Maybe it would get wider acceptance if MS named it differently. I first heard about it a few years back, and wanting to know more, I typed .NET into Google. I got back every www.*.net website on the web, but little about Microsoft. I knew C# had something to do with this, so I typed that in. Google dropped the # and returned every page with the letter C. Then I heard about ASP.NET, and decided to look that up on Google. I got back every www.*.net/*.asp page in the world, again no useful info. Finally, I gave up and installed Linux instead. I heard that mono got me .NET on Linux, and so I looked up mono. I learned alot about being careful about who I kiss, but little else.