Js clicks the button to jump to another new page

  • 2020-03-30 04:05:38
  • OfStack

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

This effect can be achieved by: onclick="window.location=' new page '".

1. Jump directly from the original form

The following code

Window.location.href =" the page you want to go to ";

2. Open the page in the new form with:

The following code

Window.open (' the page you want to go to ');

Window. The history. The back (1); Go back to the previous page

The following code

< Input type="submit" name=" submit" value=" agree "onclick=window.open(//www.jb51.net/)>

What do I do if I want to verify that the input is filled in when I click the button to submit? When the user name input or other is empty, click the button not to submit, you can do as follows.

The following code


<input type="submit" name="submit" onclick="open()"> <script language=javascript>
fuction open(){ if(!document.form_name.username.value) { alert(" Please enter user name! "); document.form_name.username.focus(); return false; }else document.form_name.action="aaa.htm"; }
</script>

So, when the value is empty, clicking the button still won't jump to another page? That's it.

JS jump page reference code

The following code

The first:
< Script language = "javascript" type = "text/javascript" >
Window. The location. Href = "login. JSP & # 63; Backurl = "+ window. The location. Href;
< / script>
The second:
< Script language = "javascript" >
Alert (" return ");
Window. The history. The back (1);
< / script>
The third:
< Script language = "javascript" >
Window. Navigate (" top. JSP ");
< / script>
Fourth:
< Script language = "JavaScript" >
The self. The location = 'top. HTM';
< / script>
Fifth:
< Script language = "javascript" >
Alert (" illegal access!" );
Top. Location = 'xx. JSP;
< / script>

= = = = = javascript pops up a selection box to jump to another page = = = = =


<script language="javascript">
<!--
function logout()...{
if (confirm(" Are you sure you want to lose your identity? Yes - select yes, no - Select cancel "))...{
window.location.href="logout.asp?act=logout"
}
}
-->
</script>

= = = = = = javascript prompt box to jump to another page = = = = =

<script language="javascript">
<!--
function logout()...{
alert(" Are you sure you want to lose your identity? ");
window.location.href="logout.asp?act=logout"
}
-->
</script>


Related articles: