JS Click button to jump to the page code

Source: Internet
Author: User

Click the button how to jump to another page? We may be required in the production of the website, because sometimes we need to do this effect, especially the button into a picture, and click on the picture to jump to the new page, how to do it?

The effect can be: onclick= "window.location= ' new page" to achieve.

1. Skip the switch directly in the original form

The code is as follows Copy Code

window.location.href= "The page you want to jump";

2, open the page in the new form with:

The code is as follows Copy Code

window.open (' You are going to jump to the page ');

Window.history.back (-1); Back to previous page


The code is:

The code is as follows Copy Code

<input type= "Submit" name= "Submit" value= "Agree" Onclick=window.open (http://www.111cn.net/) >

What do you do if you want to verify that the input is filled in when you click on the button submission? When the user name input or other empty, click the button does not submit, you can do the following methods.

The code is as follows Copy Code

<input type= "Submit" name= "Submit" onclick= "open ()" >

<script language=javascript>
Fuction Open () {

if (!document.form_name.username.value) {

Alert ("Please enter a username!") "); Document.form_name.username.focus (); return false;

}else document.form_name.action= "aaa.htm";

}
</script>

In this case, when the empty value, click the button or not jump to another page? This achieves the effect.


JS jump page reference Code

The code is as follows Copy Code

First type:
<script language= "javascript" type= "Text/javascript" >
window.location.href= "Login.jsp?backurl=" +WINDOW.LOCATION.HREF;
</script>
The second type:
<script language= "JavaScript" >
Alert ("return");
Window.history.back (-1);
</script>
The third type:
<script language= "JavaScript" >
Window.navigate ("top.jsp");
</script>
The fourth kind:
<script language= "JavaScript" >
self.location= ' top.htm ';
</script>
The fifth kind:
<script language= "JavaScript" >
Alert ("Illegal access!) ");
top.location= ' xx.jsp ';
</script>

=====javascript pop-up selection box jumps to other pages =====
<script language= "javascript"
<!--
Function logout () ... {
if (confirm) are you sure you want to log out of identity? Yes-Select OK, no-select Cancel ") ... {
window.location.href= "logout.asp?act=logout"
}
}
;
</script>
 
=====javascript pop-up prompt box jumps to other pages =====
<script language= "javascript"
<!--
Function logout () ... {
Alert ("Are you sure you want to log out of identity?") ");
window.location.href= "Logout.asp?act=logout"
}
;
</script>

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.