Browsing articles tagged with " ie6"

Using window.location in a JQuery/JavaScript Function on Internet Explorer 6 (IE6)

Aug 4, 2010   //   by the guru   //   Internet Explorer, JavaScript, JQuery  //  2 Comments

Now then, what can I say about my favourite browser that is in my view Microsoft’s best invention! Crap!

Simple as that for now. I will reserve a separate blog for discussing IE6 another time – or should I say rant. As a web developer I probably spend approximately a third of any development time fixing IE6 bugs. 2014 cannot come soon enough when Microsoft stop supporting the nightmare. Until then…

Had an interesting issue today: it turns out that if you use window.location in a function you need to make sure you return false otherwise the navigation will not work. No error, just nothing. Puh!

For example, I was doing a very simple click function using JQuery as below:

$("#test_link").click(function()
{
  window.location = 'http://www.google.co.uk/';
});

To make it work in IE6 I had to use:

$("#test_link").click(function()
{
  window.location = 'http://www.google.co.uk/';
  return false;
});

To be fair to Microsoft they are correct though. We should in fact return something in a function. It is after all good programming, but if is not semantically correct, which is clearly why IE6 does not do anything then why doesn’t it trigger an error? For me it is lazy coding, which is what the web is all about and it is a shame that we have to spend hours trying to work back to our roots to find out why a perfectly well-coded site does not work in an archaic browser. Rant over :-)