The common method and code example of JavaScript implementing page jump

Source: Internet
Author: User
Tags header

This article introduces the commonly used page jump implementation methods, including the JS php asp.net these three kinds of implementation code, there is a need to understand friends can refer to.

First to introduce the practice of JS

The code is as follows Copy Code

function Tourl (UL) {
if ("" = = UL | | Null==ul) {
Alert ("Thank you for attention");
}else{

WINDOW.OPEN (UL);//This is a new window.

window.location.href=ul;//This is directly on the current page jump

}
Return
}

This is a window.open to achieve, click to pop a window Oh,

JavaScript Popup selection box jump to other pages

The code is as follows Copy Code
<script language= "JavaScript" >
<!--
function logout () ... {
if (confirm) ("Are you sure you want to cancel your identity?") Yes-Select OK, no-select Cancel ") ... {
window.location.href= "Logout.asp?act=logout"
}
}
-->
</script>

Will prompt the user whether to confirm to pass out, if clicks is to be able to jump to logout.asp?act=logout this page.

Take a look at using HTML Refresh to jump

The code is as follows Copy Code
<?php
$url = "http://www.3ppt.com";
if (!isset ($url))
{
Exit (' No address to jump ');
}
?>

<meta http-equiv= "REFRESH" content= "5; Url= ' <?php echo $url;? > ' ">

It's going to jump to http://www.3ppt.com in 5 seconds.

The code is as follows Copy Code
PHP header () to implement the
<?php
$url = "http://www.3ppt.com";
if (Isset ($url))
{
Header ("Location: $url");
}
?>

One thing to be aware of when using the PHP header is that there must be no output before, otherwise it will go wrong (PHP header () usage).


asp.net jump method

The code is as follows Copy Code

Response.Redirect ("index.aspx"); This is much more convenient.

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.