Automatic page timing (timing) jump in ASP.NET with JS

  • 2021-06-28 12:20:23
  • OfStack

ASP.NET implements page auto-jumping (tested and available in VS2008 C#environment)


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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 runat="server">
  <title></title>
  
  <script type="text/javascript">
    var i = 5;
    
    //  Get login events and handle automatic jumps 
    window.onload = function JumpPage() 
    {
      document.getElementById("time").innerText = i;
      
      //  Timed as 0 Jump immediately after 
      i--;
      if (i < 0) 
      {
        location.replace("http://www.baidu.com");
      }
      setTimeout("JumpPage()", 1000);
    }
  </script>
</head>
<body>
  <form id="form2" runat="server">
    <div id="AutoJumpPage">
       Welcome, this page will be <span id="time" style="color: #FF0000"></span> Automatically jump to after seconds <a href="http://www.baidu.com"> Baidu </a>
      <br /><br />
       To jump now, tap directly  <a href="http://www.baidu.com" style="color: #FF00FF"> Jump now >></a>
    </div>
  </form>
</body>
</html>


Related articles: