函数代码:
document.getElementByIdx_x=function(id){
if(typeof id =='string')
return document.getElementById(id);
else
throw new error('please pass a string as a id!')
}
实例代码:
<script> <br>document.getElementByIdx_x=function(id){ <br>if(typeof id =='string') <br>return document.getElementById(id); <br>else <br>throw new error('please pass a string as a id!') <br>} <br>var timer = window.setInterval(function(){ <br>document.getElementByIdx_x('box').innerHTML = parseInt(document.getElementByIdx_x('box').innerHTML) - 1; <br>if(parseInt(document.getElementByIdx_x('box').innerHTML) < 0) <br>{ <br>window.clearInterval(timer); <br>window.location = 'http://www.jb51.net'; <br>} <br>}, 1000); <br></script>











