Use Javascript in ASP. NET to automatically redirect page timing (timing)

Source: Internet
Author: User

Use Javascript in ASP. NET to automatically redirect page timing (timing)

This article mainly introduces ASP. NET with JavaScript to achieve page timing (timing) Automatic jump, this article mainly relies on JS implementation requirements, only in ASP.. NET. For more information, see.

ASP. NET Enables automatic page Jump (tested, which can be passed in VS2008 C # environment)

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

<% @ 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;

 

// Obtain logon events and handle Automatic redirects

Window. onload = function JumpPage ()

{

Document. getElementById ("time"). innerText = I;

 

// Jump immediately after the timer is 0

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 to the <span id = "time" style = "color: # FF0000 "> </span> seconds after automatic jump to <a href =" http://www.baidu.com "> Baidu </a>

<Br/>

If you want to jump to the page immediately, click <a href = "http://www.baidu.com" style = "color: # FF00FF"> jump now >></a>

</Div>

</Form>

</Body>

</Html>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.