Ticket #2280 (closed defect: fixed)
Including cross-domain dojo build causes an error in IE (dojo is undefined)
| Reported by: | pat@… | Owned by: | jburke |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | BuildSystem | Version: | 0.4.1 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
When using the "sunday drive" easy method of including dojo (as described here: http://alex.dojotoolkit.org/?p=591) I get an intermittent error in IE6:
'dojo' is undefined
The cross-domain url I am using is as follows: http://download.dojotoolkit.org/release-0.4.1/dojo-0.4.1-xdomain-ajax/dojo.js
This appears to be caused by a bug in IE. The cross-domain url writes two script elements to the page (using document.write). The first script element loads dojo.js, and the second script element calls dojo.registerModulePath.
The error occurs because IE6 evaluates the second script element before the first script element has finished.
Note that this behavior occurs only when using document.write to place the two script elements onto the page. If you construct a test page with the two script elements directly on the page then the bug does not occur.
So if you create a file with the following text, the bug will not occur, but if you use document.write to place the following text on the page, the bug occurs:
<script type="text/javascript" src="http://download.dojotoolkit.org/release-0.4.1/dojo-0.4.1-xdomain-ajax/dojo.js">
</script>
<script type="text/javascript">
dojo.registerModulePath("dojo", "http://download.dojotoolkit.org/release-0.4.1/dojo-0.4.1-xdomain-ajax/src");
</script>
Note that this error occurs only in IE (I am using IE6 on Windows XP but have not tested other versions). Also the bug intermittently appears - if necessary clear your cache or throttle your bandwidth to make this occur. (I recommend Charles web debugging proxy for throttling bandwidth: http://www.xk72.com/charles/)