javascript实现自动跳转到首页的代码实例

最简单的方法

在网页的<head>段中添加

<meta http-equiv="refresh" content="3;url=http://要跳的页面">



方法二带有秒数走动的效果

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"
"http://www.3ppt.com /tr/xhtml1/dtd/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="content-type" content="text/html; charset=gb2312" />

<title>几秒钟后页面自动跳转</title>


    <script language=网页特效>

    function countdown(secs,surl){

    //alert(surl);


    tiao.innertext=secs;//<span>中显示的内容值

    if(--secs>0){

           settimeout("countdown("+secs+",'"+surl+"')",1000);//设定超时时间

           }

    else{

     

           location.href=surl;//跳转页面


           }

    }

    </script>




<!--脚本结束-->
</head>
<body>

    <span id="tiao">30</span>秒后将自动跳转到网站首页<script language=javascript>countdown(5,'http://www.3ppt.com');</script>

</body>
</html>