How to jump to another page when clicking the button? We may need it in website production, because sometimes we need to do such an effect, especially when we make a button into an image, and when clicking on the image to jump to a new page, how can we do it?
This effect can be achieved by: onclick="window.location='new page'".
1. Use it directly in the original form
The code is as follows
window.location.href="The page you want to jump";
2. Open the page in a new form with:
The code is as follows
window.open('The page you want to jump to');
window.history.back(-1); Return to the previous page
The code is as follows
<input type="submit" name="Submit" value="Agree" onclick=window.open(//www.VeVB.COM/)>
What should I do if I want to verify that the input is filled in when I click the button to submit? When the user name is entered or other empty, click the button to not submit. You can do it as follows.
The code is as follows
The code copy is as follows:
<input type="submit" name="submit" onclick="open()">
<script language=javascript>
functionality open(){
if(!document.form_name.username.value) {
alert("Please enter the user name!"); document.form_name.username.focus(); return false;
}else document.form_name.action="aaa.htm";
}
</script>
In this way, when the value is empty, clicking the button will still not jump to another page? This achieves the effect.
JS jump page reference code
The code is as follows
The 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 type:
<script language="JavaScript">
self.location='top.htm';
</script>
The fifth type:
<script language="javascript">
alert("Illegal access!");
top.location='xx.jsp';
</script>
====================================================================================�
The code copy is as follows:
<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>
====================================================================================�
The code copy is as follows:
<script language="javascript">
<!--
function logout()...{
alert("Are you sure you want to cancel your identity?");
window.location.href="logout.asp?act=logout"
}
-->
</script>