Opened 9 years ago

Closed 8 years ago

#12225 closed defect (fixed)

Problem with xdomain loading, setTimeout and IE

Reported by: Yousuf Haider Owned by: James Burke
Priority: high Milestone: 1.7
Component: Loader Version: 1.5
Keywords: Cc:
Blocked By: Blocking:


In one of our pages we were running into an issue with cross domain loaders and IE. I was able to distill the problem down into an easily reproducible case. Place the following markup in a html file

<!DOCTYPE html>
    <script type="text/javascript">
        dojo.addOnLoad(function() {
            setTimeout(loadStackContainer, 0);
        function loadStackContainer() {
            var div = dojo.byId('result');
            dojo.addOnLoad(function() {
                if (dijit && dijit.layout && dijit.layout.StackContainer && dijit.layout.StackContainer.prototype) {
                    div.innerHTML = "Stack container loaded properly";
                } else {
                    div.innerHTML = "Stack Container wasn't loaded dude!";
    <button type="button" onclick="setTimeout(loadStackContainer, 0);">Click here to load stack container again </button>
    <div id='result'>Initial</div>

Access this page in IE and you will notice that the StackContainer? doesn't get loaded properly.

What we are doing here is pretty simple. We have an xdomain version of dojo being used.

  1. We have a addOnLoad() function that calls a setTimeout.
  1. The setTimeout calls a function that calls a function does a dojo.require on a module (StackContainer?) that doesn't exist on the page yet.
  1. Dojo uses the xdomain loader to load it. Since we are using an xdomain build the code that is supposed to use the StackContainer? is actually inside another addOnLoad().
  1. Inside the second addOnload() we expect the StackContainer? to be loaded as per Dojo's documentation. Also this would work in all browsers except for IE.
  1. What actually happens on IE is that we do have a stub available but StackContainer? isn't really loaded even on addOnLoad()

This problem goes away if we do two things:

  1. Do not call loadStackContainer() using a setTimeout().
  1. Or if we call loadStackContainer() after page has been loaded. For eg. when clicking on the button.

For some reason this is a problem in IE only.

(note that some of you may wonder why I have the setTimeout in the first place. This is just a very distilled version of what we are actually doing on the page and there are other reasons why we need a setTimeout())

Breaks on IE 7/8

Change History (2)

comment:1 Changed 9 years ago by bill

Owner: changed from anonymous to James Burke

comment:2 Changed 8 years ago by bill

Component: GeneralLoader
Milestone: tbd1.7
Resolution: fixed
Status: newclosed

Confirmed broken in 1.6 but working in 1.7.

Note: See TracTickets for help on using tickets.