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> |