Reference dojo. before js, it is best to declare the djConfig object to load the dojo. js can get the set value. Although dojo supports post-loading setting after version 0.3 and later, we strongly recommend that you use the code to declare djConfig as the first script:
A complete djConfig object is defined as follows (values are the default values of dojo)
Js Code
Var djConfig = {
IsDebug: false,
DebugContainerId :"",
BindEncoding :"",
AllowQueryConfig: false,
BaseScriptUri :"",
ParseWidgets: true
SearchIds: [],
BaseRelativePath :"",
LibraryScriptUri :"",
IePreventClobber: false,
IeClobberMinimal: true,
PreventBackButtonFix: true,
DebugContainerId is also related to debugging. If this parameter is not specified, the debugging information will directly use document. write output, which may damage the overall layout of the page. Therefore, you can specify any html element id that can be used as the container's html element as the debugging information output container.
AllowQueryConfig. This attribute specifies whether dojo allows reading related attributes in djConfig from parameters in the page url. If the value is true, dojo preferentially reads other attributes of djConfig from url parameters. For example: http: // server/dojoDemo.htm? DjConfig. debugContainerId = divDebug
BaseScriptUri, which generally does not need to be set. dojo will automatically reference dojo according to your reference. set this value in the js path, for example, <script src = ".. /dojo. js "type =" text/javascript "> </script>. The automatically obtained value is .. /dojo/
Ps: If you have multiple projects that need to reference dojo. js at the same time, we recommend that you use dojo as an independent project. You can use absolute paths when referencing them.
ParseWidgets, which controls whether dojo automatically parses html elements with dojoType as corresponding widgets. If you do not use any widgets, it is recommended to set it to false to accelerate the loading of dojo.
SearchIds, which is a string array that defines the IDs of all html elements to be parsed as Widgets. If the ID is not included in the html element, it will not be parsed. When the array is an empty array, all elements with dojoType will be parsed.
Another bindEncoding is used to set the encoding method of the default bind request.
Dojo. raise throws an exception.
Dojo. errorToString converts an exception to a string
Js Code
Try {
Dojo. raise ("Print failed", new Error ("file does not exist "));
} Catch (e)
{
Alert (dojo. errorToString (e ));
}
IsDebug is a useful attribute. If it is set to true, all the output of dojo. Debug is valid. It should be set to true during development and false during release.
1. Calculate the size of a block in HTML
Js Code
Dojo. style. getOuterWidth/dojo. style. getOuterHeight
Dojo. style. getInnerWidth/dojo. style. getInnerHeight
2. Modify CSS
Js Code
Dojo.html. addClass (node, className)
Dojo.html. prependClass (node, className)
Dojo.html. removeClass (node, className)
Dojo.html. replaceClass (node, className, oldClassName)
3. Animation
Js Code
FadeIn, fadeShow, fadeOut, fadeHide,
WipeIn, wipeOut
Explode, implode
Highlight, unhighlight
Example:
Function wipeOut (elId ){
Dojo. lfx. wipeOut (elId, 300). play ();
}
Function wipeIn (elId ){
Dojo. lfx. wipeIn (elId, 300). play ();
}
Function fadeOut (elId ){
Dojo.lfx.html. fadeOut (elId, 300). play ();
}
Function fadeIn (elId ){
Dojo.lfx.html. fadeIn (elId, 300). play ();
}
Function opacity (elId ){
Dojo.html. setOpacity (elId, 0.5 );
}
Function opacityApp (){
$ ("# Opacity"). click (function (){
Opacity ('fadelm ');
});
}
Function fadeInApp (){
$ ("# Fadein"). click (function (){
FadeIn ('fadeelm ');
});
} Dojo. lang module:
Dojo. lang. mixin adds methods and attributes of an object to another object:
Js Code
Var s1 = {name: "TestObj", test1: function () {alert ("this is test1! ");}}
Var s2 = {value: 1000, test2: function () {alert ("this is test2! ");}}
Var d = {};
Dojo. lang. mixin (d, s1, s2); // after execution, d has all the attributes and methods of s1 and s2. d. test1 ();
Dojo. lang. extend is the prototype Extension Method and attribute of the specified class:
Js Code
TestClass = function (){};
Dojo. lang. extend (TestClass, {name: "demo", test: function () {alert ("Test! ");}});
Var o = new TestClass ();
// TestClass does not have the test method, but extend will have the test method o. test ();
Dojo. lang. find = dojo. lang. indexOf finds the position of the specified object in the specified array:
Js Code
Var arr = [1, 2, 3, 2, 1];
Dojo. lang. find (arr, 2); // will return 1
Dojo. lang. extrasdojo. lang. setTimeout:
Js Code
Function onTime (msg) {dojo. debug (msg )}
Dojo. lang. setTimeout (onTime, 1000, "test"); // The debugging information "test" is output in 1 second"
DOM operations
Js Code
Dojo. dom. isNode
Dojo. dom. getTagName
Dojo. dom. firstElement
Dojo. dom. lastElement
Dojo. dom. nextElement
Dojo. dom. prevElement
Dojo. dom. moveChildren (srcNode, destNode, trim)
Dojo. dom. copyChildren (srcNode, destNode, trim)
Dojo. dom. removeChildren (node)
Dojo. dom. replaceChildren (node, newChild)
Dojo. dom. removeNode (node)
Dojo. dom. getAncestors
Dojo. dom. getAncestorsByTag
Dojo. dom. innerXML
Dojo. dom. createDocumentFromText
Dojo. dom. prependChild
Dojo. dom. insertAfter
Dojo. dom. insertAtPosition
Dojo. dom. textContent
I would like to introduce you so much and wish you a pleasant weekend!