Common methods and code examples for page Jump using javascript

Source: Internet
Author: User

This article introduces the commonly used page Jump implementation methods, including js php asp.net implementation code. For more information, see.

Let's first introduce the js practices.

The Code is as follows: Copy code

Function toUrl (ul ){
If ("" = ul | null = ul ){
Alert ("thanks for your attention ");
} Else {

Window. open (ul); // This is the new window

// Window. location. href = ul; // This is directly redirected to the current page

}
Return;
}

This is implemented by window. open. Click it to bring up a window,

The selection box pops up in javascript to jump to other pages

 

The Code is as follows: Copy code
<Script language = "javascript">
<! --
Function logout ()...{
If (confirm ("are you sure you want to log out of your identity? Yes-Select OK, no-select cancel "))...{
Window. location. href = "logout. asp? Act = logout"
}
}
-->
</Script>

Will the user be prompted to confirm the exit? If you click yes, it will jump to logout. asp? Act = logout.

Use html refresh to jump

 

The Code is as follows: Copy code
<? Php
$ Url = "http://www.3ppt.com ";
If (! Isset ($ url ))
{
Exit ('no jump address you ');
}
?>

<META HTTP-EQUIV = "REFRESH" CONTENT = "5; URL = '<? Php echo $ url;?> '">

It will jump to http://www.3ppt.com in 5 seconds.

 

The Code is as follows: Copy code
Php header () to implement
<? Php
$ Url = "http://www.3ppt.com ";
If (isset ($ url ))
{
Header ("Location: $ url ");
}
?>

When using php headers, note that there must be no output in front of the header. Otherwise, an error occurs (php header () usage ).


Asp.net jump Method

The Code is as follows: Copy code

Response. Redirect ("index. aspx"); this is much easier

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.