zoukankan      html  css  js  c++  java
  • .Net 网页几秒后跳转页面的实现

    在很多的时候我们希望网页在经过几秒后进行跳转,我稍微总结了一下我用的的三个方法:

    1.  后台:

    if (Session["UserName"] == null)
                {
                    Response.AppendHeader("Refresh", "3; URL=Login.aspx");
                    Panel1.Visible = false;
                    Panel2.Visible = true;
                }

       前台:

    View Code
    <asp:Panel ID="Panel2" runat="server">
                     <center><p> 亲,你还没登录 去    <a href="Login.aspx">登录吧!</a>   3秒后自动跳转。</p></center> 
                    </asp:Panel>

    2.  通过JS跳转,下面是一个例子:

    View Code
    <span id="jumpTo">您还没有登录,5</span>秒后自动跳转到登录页面。
        <script type="text/javascript">    countDown(5, 'login.aspx');</script>
    
    <script type="text/javascript">
            function countDown(secs, surl) {
                //alert(surl);    
                var jumpTo = document.getElementById('jumpTo');
                jumpTo.innerHTML = secs;
                if (--secs > 0) {
                    setTimeout("countDown(" + secs + ",'" + surl + "')", 1000);
                }
                else {
                    location.href = surl;
                }
            }    
    </script> 

    3.通过在网页的头部进行一个meta声明:

    <meta http-equiv="Refresh" content="5;URL=Index.aspx" />
  • 相关阅读:
    UVA 11997 K个最小和
    UVALive 3135阿格斯
    UVA 10635 王子和公主
    UVA11991线性查询
    UVA1339仿射和换位密码
    UVA 10382喷水设施
    LA2965字符串合并
    FatMouse's Speed--hdu1160(dp+输出路径)
    Dividing--hdu1059(动态规划)
    Piggy-Bank--hdu1114(完全背包)
  • 原文地址:https://www.cnblogs.com/ruicky/p/2471982.html
Copyright © 2011-2022 走看看