catch(e) {
alert(dojo.errorToString(e)); }
dojo.render
系统环境对象
dojo.render.name 返回 browser ,说明是工作在浏览器下 dojo.render.ver 返回 4 ,返回 dojo 版本
dojo.os.win 返回 true 说明操作系统是 Windows dojo.os.linux 返回 true 说明操作系统是 Linux dojo.os.osx 返回 true 说明操作系统是 MacOS
dojo.html.ie 返回 true 说明浏览器是 Internet Explorer dojo.html.opera 返回 true 说明浏览器是 Opera
dojo.html.khtml 返回 true 说明浏览器是 Konqueror dojo.html.safari 返回 true 说明浏览器是 Safari
dojo.html.moz 返回 true 说明浏览器是 Mozilla FireFox dojo.svg.capable 返回 true 说明浏览器支持 svg dojo.vml.capable 返回 true 说明浏览器支持 vml dojo.swf.capable 返回 true 说明浏览器支持 swf
dojo.swt.capable 返回 true 说明浏览器支持 swt (IBM 开发的 Standard Widget Toolkit) 如果 dojo.html.ie 为 true 的话
dojo.html.ie50 返回 true 说明浏览器是 IE 5.0 dojo.html.ie55 返回 true 说明浏览器是 IE 5.5 dojo.html.ie60 返回 true 说明浏览器是 IE 6.0 dojo.html.ie70 返回 true 说明浏览器是 IE 7.0 dojo.addOnLoad
可以加载指定函数到 window.load 时执行,好处就是可以很方便的在 window.load 时执行多个函数 Usage Example:
dojo.addOnLoad(init); //init 是一个函数
dojo.addOnLoad(myObject, init); //init 是 myObject 对象的一个方法 dojo.require
如果你想调用一个模块的对象的时候,你应该首先用 dojo.require 来请求这个模块,dojo 会根据 你的请求自动取得相应的 js 文件,并加载到内存中,这样你才能调用或创建其中的对象 dojo 会自动维护已加载的模块列表,所以是不会重复加载模块的 Usage Example:
dojo.require(\
dojo.requireIf=dojo.requireAfterIf
可以根据指定的条件来决定是否加载指定的模块 Usage Example:
dojo.requireIf(dojo.html.ie, \如果 dojo.html.ie 为 true,才会加载 dojo.html 模 块
dojo.provide
除非你要开发自己的模块,不然是用不到这个方法的,你可以这句看成是向系统注册这个模块名称 Usage Example:
dojo.provide(\dojo.exists
判断指定对象是否具有指定名称的方法 Usage Example:
dojo.exists(dojo, \dojo.hostenv.getText 返回指定 url 的内容
PS: 由于浏览器的安全限制,因此只能用于取得同域名的 url 的内容,否则会报告权限不够 Usage Example:
aSync = false; //同步,确保返回内容不为 null silent = true; //不抛出错误
s = dojo.hostenv.getText(\返回 Google 的首页的 HTML
alert(s); dojo.debug
输出调试信息,如果在 djConfig 中指定了 debugContainerId,则输出到指定的 console 容器 中,否则直接 document.write
所有的调试信息均以 DEBUG: 开头 Usage Example:
dojo.debug(\这是调试信息\dojo.hostenv.println
与 dojo.debug 类似,不同的是,输出内容没有 DEBUG: Usage Example:
dojo.hostenv.println(\这是一般的输出信息\dojo.debugShallow
输出指定对象的全部信息(Shallow 说明并不会遍历到下一级别的对象属性)以供调试 Usage Example:
dojo.debugShallow(dojo.render.html);
以上全部是自己阅读源代码写的总结,如有错误,还请指明。 模块:dojo.validate.creditCard
DOJO 常用的验证函数,dojo 提供了几乎全方位的验证函数 dojo.provide(\dojo.validate.isValidCreditCard
dojo.validate.isValidCreditCard (/*String|Int*/value, /*String*/ccType); Summary:
checks if type matches the # scheme, and if Luhn checksum is accurate (unless its an Enroute card, the checkSum is skipped) Value: Boolean
dojo.validate.isValidCreditCardNum ber
dojo.validate.isValidCreditCardNumber (/*String|Int*/value,/*String?*/ccType) //Summary: // checks if the # matches the pattern for that card or any card types if none is specified // value == CC #, white spaces and dashes are ignored // ccType is of the values in cardinfo ‐‐ if Omitted it it returns a | delimited string of
matching card types, or false if no matches found //Value: Boolean
dojo.validate.isValidCvv
dojo.validate.isValidCvv (/*String|Int*/value, /*String*/ccType); //Summary: // returns true if the security code (CCV) matches the correct format for supplied ccType //Value: Boolean
模块:dojo.validate.common dojo.validate.isText
dojo.validate.isText (/*String*/value, /*Object?*/flags): isText accepts a parameter, and determines if it is a string value:
value to test. returns: Boolean
// summary: // Checks if a string has non whitespace characters. // Parameters allow you to constrain the length. //
// value: A string
// flags: {length: Number, minlength: Number, maxlength: Number}
// flags.length If set, checks if there are exactly flags.length number of characters.
// flags.minlength If set, checks if there are at least flags.minlength number of characters. // flags.maxlength If set, checks if there are at most flags.maxlength number of characters. dojo.validate.isInteger
dojo.validate.isInteger (/*String*/value, /*Object?*/flags):
isInteger accepts a parameter, and determines if it is an integer. Note that this returns true is it is string integer, or a number
integer. value:
value to test. returns: Boolean
// summary: // Validates whether a string is in an integer format //
// value A string
// flags {signed: Boolean|[true,false], separator: String}
// flags.signed The leading plus-or-minus sign. Can be true, false, or [true, false]. // Default is [true, false], (i.e. sign is optional).
// flags.separator The character used as the thousands separator. Default is no separator. // For more than one symbol use an array, e.g. [\dojo.validate.isRealNumber
dojo.validate.isRealNumber (/*String*/value, /*Object?*/flags):
isNumber accepts a parameter, and determines if it is a number. Note that this also returns true is it is string number. value:
value to test. returns: Boolean
// summary: // Validates whether a string is a real valued number. // Format is the usual exponential notation. //
// value: A string // flags: {places: Number, decimal: String, exponent: Boolean|[true,false], eSigned: Boolean|[true,false], ...}
// flags.places The integer number of decimal places.
// If not given, the decimal part is optional and the number of places is unlimited. // flags.decimal The character used for the decimal point. Default is \
// flags.exponent Express in exponential notation. Can be true, false, or [true, false]. // Default is [true, false], (i.e. the exponential part is optional).
// flags.eSigned The leading plus-or-minus sign on the exponent. Can be true, false, // or [true, false]. Default is [true, false], (i.e. sign is optional). // flags in regexp.integer can be applied. dojo.validate.isCurrency
dojo.validate.isCurrency (/*String*/value, /*Object?*/flags) // summary: // Validates whether a string denotes a monetary value. // value: A string
// flags: {signed:Boolean|[true,false], symbol:String, placement:String, separator:String, // fractional:Boolean|[true,false], decimal:String} // // // // //
flags.signed The leading plus‐or‐minus sign. Can be true, false, or [true, false]. Default is [true, false], (i.e. sign is optional). flags.symbol A currency symbol such as Yen \?\?\?\Default is \flags.placement The symbol can come \the number or \ Default is \// //
flags.separator The character used as the thousands separator. The default is \
flags.fractional The appropriate number of decimal places for fractional currency (e.g. cents) // //
Can be true, false, or [true, false]. Default is [true, false], (i.e. cents are optional). flags.decimal The character used for the decimal point. Default is \dojo.validate.isInRange
dojo.validate.isInRange (/*String*/value, /*Object?*/flags) //summary: // Validates whether 是否 a string denoting 表示 an integer, // real number, or monetary 货币 value is between a max and min. //
// value: A string
// flags: {max:Number, min:Number, decimal:String} //
flags.max A number, which the value must be less than or equal <= to for the validation to be true. //
flags.min A number, which the value must be greater than or to for the validation to be true. //
flags.decimal The character used for the decimal point. Default is \例如:dojo.validate.isInRange(\‐1\dojo.validate.isNumberFormat
dojo.validate.isNumberFormat = function(/*String*/value, /*Object?*/flags) // summary: // Validates any sort of number based format //
// description: // Use it for phone numbers, social security numbers, zip‐codes, etc. // The value can be validated against one format or one of multiple formats. // // Format // // # ?
Stands 容忍 for a digit, 0‐9. Stands 容忍 for an optional digit, 0‐9 or nothing. // //
All other characters must appear literally in the expression. // Example // // // // //
\‐####\‐> (510) 542‐9742 \‐#### x#???\‐> (510) 542‐9742 x153 \‐##‐####\‐> 506‐82‐1089 \‐####\‐> 98225‐1649 i.e. social security number i.e. zip code
// value: A string
// flags: {format:String} //
flags.format A string or an Array of strings for multiple formats.
equal >=dojo.validate.isValidLuhn
dojo.validate.isValidLuhn (/*String*/value) //summary: Compares 比较 value against the Luhn algorithm 算法 to verify 验证 its integrity 完 整
模块:dojo.validate.check dojo.validate.check
dojo.validate.check (/*HTMLFormElement*/form, /*Object*/profile)
// summary: validates user input of an HTML form based on input profile //
// description: // returns an object that contains several methods summarizing the results of the validation //
// form: form to be validated
// profile: specifies how the form fields are to be validated
// {trim:Array, uppercase:Array, lowercase:Array, ucfirst:Array, digit:Array, // required:Array, dependencies:Object, constraints:Object, confirm:Object} // Essentially private properties of results object dojo.validate.evaluateConstraint
dojo.validate.evaluateConstraint (profile, /*Array*/constraint, fieldName, elem) // summary: // Evaluates dojo.validate.check() constraints that are specified as array // arguments //
// description: The arrays are expected to be in the format of: // // //
constraints:{
fieldName: [functionToCall, param1, param2, etc.], fieldName: [[functionToCallFirst, param1],[functionToCallSecond,param2]] // // } // This function evaluates a single array function in the format of: // //
[functionName, argument1, argument2, etc] // The function will be parsed out and evaluated against the incoming parameters. //
// profile: The dojo.validate.check() profile that this evaluation is against. // constraint: The single [] array of function and arguments for the function. // fieldName: The form dom name of the field being validated. // elem: The form element field. 模块: dojo.date.common dojo.date.setDayOfYear
dojo.date.setDayOfYear(/*Date*/dateObject, /*Number*/dayOfYear) summary: sets dateObject according to day of the year (1..366) dojo.date.getDayOfYear
dojo.date.getDayOfYear (/*Date*/dateObject)
summary: gets the day of the year as represented by dateObject dojo.date.setWeekOfYear
dojo.date.setWeekOfYear (/*Date*/dateObject, /*Number*/week, /*Number*/firstDay) dojo.date.getWeekOfYear
dojo.date.getWeekOfYear(/*Date*/dateObject, /*Number*/firstDay) dojo.date.setIsoWeekOfYear
dojo.date.setIsoWeekOfYear (/*Date*/dateObject, /*Number*/week, /*Number*/firstDay)