Dojo   发布时间:2019-10-11  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了dojo.addOnLoad大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

dojo.addOnLoad(Function fn)

Sooner or later,every Javascript progrAMMer tries something like this:@H_772_3@

<script>
if (dayOfWeek == "Sunday" ){
document. @H_814_28@musicPrefs. other. value = "Afrobeat";
}
</script>
<form name= "musicPrefs">
<input type= "text" name= "other">
...

It doesn't work because the "other" control is not defined yet. You can move the code to the bottom of the page,but that removes the linear nature of HTMl. If you're reading the code,you want to zero in on a control,and see the code that influences it close by.@H_772_3@

dojo.addOnLoad(...) defers script execution until all the HTML is loaded. So this code:@H_772_3@

function setAfrobeat (){
document. @H_814_28@musicPrefs. other. value= "Afrobeat";
}
dojo. addOnLoad (setAfrobeat );

conveniently replaces the one above. When the function is small,you may prefer to write it inline:@H_772_3@

dojo. addOnLoad (
function (){
document. @H_814_28@musicPrefs. other. value= "Afrobeat";
}
)
;

This is the function literal or anonymous function construct of JavaScript. If it looks really,really wierd to you,take a peek ahead at Functions as Variables for an explanation.@H_772_3@

大佬总结

以上是大佬教程为你收集整理的dojo.addOnLoad全部内容,希望文章能够帮你解决dojo.addOnLoad所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。