dijit.byId doesn't work on IE8 with dojo.addOn

2019-07-16 05:23发布

问题:

When I load this script with IE8, I've got exception Object does not support this property or method. But it works with other browsers.

I use dijit 1.3.1 and I don't understand.

dojo.addOnLoad(init);
var DG;
var datas;

function init(){
    DG = dijit.byId("DG");
}

I've had parseOnload: true but it changes anything.

<script type="text/javascript" src="dojo/dojo.js"
        djConfig="parseOnLoad: true">
</script>

回答1:

This migth probably not fix the problem, but the function init() is used before it was declared. Try this:

    var DG;
    var datas;

    function init(){
        DG = dijit.byId("DG");
    }

    dojo.addOnLoad(init);

Does it work?