当前位置: 首页 > 图文教程 > 网络编程 > Javascript > js函数使用技巧之 setTimeout(function(){},0)

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 js函数使用技巧之 setTimeout(function(){},0)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 292 ::
收藏到网摘: n/a

setTimeout的作用是将函数推迟第二参数设定的毫秒数后再执行,如果是0,就意味着浏览器要马上执行该函数,但是浏览器解析到setTimeout,虽然会"立刻"执行 这个立刻的结果是:
浏览器会在文档内容处于稳定状态后立刻执行,这样就达到了和<script defer='defer'>或者<body onload="fun()">一样的效果。
更应该看到的是,此函数更优于上述方法,前面两个函数只能静态时刻处理(文档第一次载入的时候),而在系统开发中,常常由于查询、更新等操作后,文档的内容会刷新,这样就可以利用setTimeout的特点,使代码能在页面内容稳定后再执行!