《dojo 边学边用》(二), djConfig配置解说
djConfig是dojo库的一个全局配置开关。或者说是对dojo全局设置的对象。
通过它,可以其控制dojo的行为。
首先我们需要在引用dojo.js前声明djConfig对象,以便在加载dojo.js的时候能够取得所设置的值,
PS:虽然在0.3版本以后dojo支持在加载后设置,但是强烈建议你把声明djConfig的代码作为第一段script。
一个完整的djConfig对象定义如下(值均为dojo的默认值)
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
<
script type
=
"
text/javascript
"
>
var djConfig = {
isDebug: false ,
debugContainerId: "" ,
bindEncoding: "" ,
allowQueryConfig: false ,
baseScriptUri: "" ,
parseWidgets: true
searchIds: [],
baseRelativePath: "" ,
libraryScriptUri: "" ,
iePreventClobber: false ,
ieClobberMinimal: true ,
preventBackButtonFix: true ,
};
< / script>
var djConfig = {
isDebug: false ,
debugContainerId: "" ,
bindEncoding: "" ,
allowQueryConfig: false ,
baseScriptUri: "" ,
parseWidgets: true
searchIds: [],
baseRelativePath: "" ,
libraryScriptUri: "" ,
iePreventClobber: false ,
ieClobberMinimal: true ,
preventBackButtonFix: true ,
};
< / script>
//在dojo 1.4开始,引入了dojo.ready(); 和jQuery的ready方法很像。估计是有意学习juery这种自然语意化的编程语言。
如下代码中的dojo.ready的用法。实际上dojo.ready()是dojo.addOnLoad()方法的一个别名而已!
<
html
>
< head >
< title > dojo test </ title >
< script type ="text/javascript" src ="js/dojo.js" ></ script >
</ head >
< body >
< script type ="text/javascript" >
dojo.ready( function () {
dojo.byId( " box " ).setAttribute( " class " , " tbox " );
});
</ script >
< div id ="box" ></ div >
</ body >
</ html >
< head >
< title > dojo test </ title >
< script type ="text/javascript" src ="js/dojo.js" ></ script >
</ head >
< body >
< script type ="text/javascript" >
dojo.ready( function () {
dojo.byId( " box " ).setAttribute( " class " , " tbox " );
});
</ script >
< div id ="box" ></ div >
</ body >
</ html >
下面我们再看看dojo.addOnLoad();
<
html
>
< head >
< title > dojo test </ title >
< script type ="text/javascript" src ="js/dojo.js" ></ script >
</ head >
< body >
< script type ="text/javascript" >
dojo.addOnLoad( function () {
dojo.byId( " box " ).setAttribute( " class " , " tbox " );
});
</ script >
< div id ="box" ></ div >
</ body >
</ html >
< head >
< title > dojo test </ title >
< script type ="text/javascript" src ="js/dojo.js" ></ script >
</ head >
< body >
< script type ="text/javascript" >
dojo.addOnLoad( function () {
dojo.byId( " box " ).setAttribute( " class " , " tbox " );
});
</ script >
< div id ="box" ></ div >
</ body >
</ html >
are you ready!