Friday, April 20, 2012

Internet Explorer 7-8 and KnockoutJS

Recently, I've been working on a project that requires IE7 minimum support and KnockoutJS. While Knockout supposedly supports IE6+,  it can be a little rough around the edges when it comes to the archaic Internet Explorers 7 and 8.

Here's a few of the hurdles I've come across so far:

IE 7&8 require quotes around reserved words, such as "class":

<div data-bind="attr: { 'class': cssclass }" >

IE 7 requires you use 'className' instead of 'class':

<div data-bind="attr: { 'class': cssclass, 'className': cssclass }" >

Not knockout specific, but IE7&8 do not support commas at the end of arrays [1,2,3,] - they will add an additional null element to the end of the array.

IE7 does not allow knockout comment bindings in <select> tags

IE7&8 may not support knockout's shorthand tags in some instances:

<div data-bind="..." />

IE7 does not include a native JSON.stringify that is used by ko.toJSON. You will need to include a helper shim.


  1. Hi i m having trouble with ie 7 and 8 which looks like it along the same lines as what you ve mentioned here i was wondering if there is anything glaringly obvious with my code:
    i know its the knockout that is stopping the page working as when i rem it out the page works again...

  2. Hi i m having an issue which looks similar to the one you ve come across please see:
    any suggestions on how to improve my code to make it work in ie 7/8..? Thanks - just seeing your blog has given me hope!!