Monday, March 17, 2008

IE6 problem with Dojo: Could not load 'dojo.parser'

I encountered this problem when testing with IE 6:

Error: Could not load 'dojo.parser'; last tried './parser.js'

After researching it a bit, it usually occurs as the result of a script that loads before the dojo stuff and which does a document.write. Apparently this confuses dojo. The solution is to use the baseUrl property of djConfig to manually specify the base path (the path to the dojo.js file):
      <script type="text/javascript" src="../dojo_tools/dojo/dojo.js"
djConfig="parseOnLoad: true, baseUrl: '/dojo_tools/dojo/'"></script>

Note the baseUrl should have a trailing '/'.

When dojo loads, if no baseUrl is provided, dojo will try to dynamically determine the base url. However, other scripts can interfere with this (at least on IE), so manually specifying it fixes it.

No comments: