<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <script type="text/javascript"> window.onload =function() { var i = 4; setInterval(function(){ if(i == 0) { location.href = "http://www.baidu.com/"; } document.getElementById("test").innerHTML = i--; },1000); }; </script> </head> <body> <span id="test">5</span>秒后自动跳转 </body> </html>