internet explorer

jQuery Advice For Dealing With Stupid Internet Explorer

It feels so good getting rid of that many long Javascript lines, sorry, ECMAscript, and playing with some jQuery and DOM. Well, at least until you meet with that browser which ignores so many web standards: Internet Explorer, unfortunately still used by a big bunch of naive users who don't know there are way better options out there.

This week I had to modify a lot of jQuery code to get it working with that horrible browser from Redmond. And the job is even harder without a tool like Firebug. Internet Explorer just spits a line number when there's an error, often without a file name, or just cryptic messages.

I refuse to install any other Microsoft application just to debug their errors, I prefer thinking, changing some code and seeing if line numbers change. It's a very old fashion way of debugging but it works.

One of the problems I found while working with Internet Explorer and jQuery involved using the html() method to change some element's content. I was able to solve this by modifying some parent() or even using remove() and then append() or after() (see jQuery docs). However, I haven't found any logic for most of these issues yet, in some cases html() worked but quite often Internet Explorer died showing a run time error.

Also, while designing a jQuery enabled calendar using an HTML table I realized that correctly using thead and tbody could make a difference. It's better to have a correctly structured table to avoid Internet Explorer complaining.

Making your web application run with Internet Explorer is not an impossible task but takes a good amount of time and can make you think about killing yourself while listening to a Steve Ballmer interview, yeah, that horrible.

I guess that many web developers, like myself, are already thinking on increasing their fees when some job requires dealing with Internet Explorer, not a bad idea, really.

Javascript Expected Identifier Error On Internet Explorer

A really weird thing was happening with some jQuery code, I was getting this error in both Internet Explorer 6 and 7: Expected Identifier.

I googled a little and found this could happen if you included an extra comma in some expressions but that wasn't my case.

Some coffees later I found the offending code was:

var class = $(this).parent().attr('class');

Yep, class seems to be a reserved word in Internet Explorer, thanks again Microsoft for making web developers lives so difficult.

I just changed the variable name to fix the error, something like this:

var tabClass = $(this).parent().attr('class');

A little later I found another mention of the class problem, hell!, where was this article when I was looking for the fix? It seems you can't set classes with jQuery's attr() method in Internet Explorer either, well, I guess that's why we have addClass() and removeClass().

Internet Explorer 7 Running on Linux

Good news for web developers running Linux: IEs 4 Linux 2.5 Beta 2 is now available and can run Internet Explorer 7.

Just run the following command during installation:

ies4linux --beta-install-ie7

I'm sure this will help many of us, Linux lovers web developers.

Important: This is just the engine of Internet Explorer 7, the user interface looks like version 6, but that's irrelevant when you just want to test a design.