Javascript issues in Internet Explorer

Behaviour:

Object doesn’t support this property or method.

javascript_internet_explorer_error

Common issues:

  • namespace conflicts. Avoid conflicts between javascript variable names (objects, functions etc.) and the name property of html tags. Internet Explorer automatically makes these tag names global variables. One best practice is to use your own namespace for your javascript (e.g. one or more global dictionaries/classes containing all your classes, functions, variables and objects as properties).
  • Declaring variables only by initialization. Try and use the “var” keyword at all times.
  • Caching. The js linked files are loaded from cache, while there is a new version available on server. You could use a GET parameter in the inclusion path which you will need to change with each update. E.g. “<script type=’text/javascript’ src=’/media/js/my.js?v=23′></script>”. The same applies for css and img files.
  • [Not verified] Calling methods to dom objects that are placed within hidden containers (e.g. a hidden div).
  • [Not verified ]jQuery chained calls. E.g. jQuery(“#adiv”).addChild(…).hide(). Just expand them: jQuery(“#adiv”).addChild(..); jQuery(“#adiv”).hide();

Interesting comments and my source of inspiration here.