Login Register

IE error on every dojotoolkit.org page

[moved to support where it might get seen]
I'm learning about dojo, and I'm intrigued, but it's a bit frustrating browsing this site in Internet Explorer. Almost every page on the dojotoolkit.org site has some javascript including:

dojo.isString=function(it){return typeof it=="string"||it instanceof String;};

However, in this case the variable 'it' is undefined, and the instanceof gives an error in Internet Explorer version 7. (My IE is configured to give an alert on Javascript errors.) Same thing in IE 6. No error visible in Mozilla (though Mozilla also doesn't like x instanceof String if x is undefined).

One might reasonably ask if this is what would happen on one's own site if dojo were used.

Perhaps the isString logic could be

dojo.isString=function(it){if(typeof it=="undefined") return false; return typeof it=="string"||it instanceof String;};

In any case, this isString() is called from dojo.connect:

_f3.push(dojo.isString(a[0])?null:a[i++],a[i++])
//where a[0] was from document.body:
dojo.connect(document.body, "onload", function(){
        //      make sure any images in the blog section is no bigger than 400px
        dojo.query(".latest-news-teaser img").forEach("if(dojo.style(item, 'width')>400){ item.style.width = '400px'; }");
});

I got lost figuring why document.body turns into null or undefined in here.

document.body is probably

document.body is probably null because you arent waiting until dojo.addOnLoad() fires meaning the dom isnt constructed.

-Karl