In JavaScript jump to the page through the prompt box
- 2020-12-19 20:54:54
- OfStack
To jump to the page through the prompt box, the specific code is as follows:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-">
<title>Document</title>
</head>
<body>
<script>
window.onload = function(){ // Set to execute when the page loads
var btn =document.getElementsByTagName("button")[] // To obtain btn The element
btn.onclick = function(){ // to button add 1 Single click event
var answer = confirm(" Would you like to visit ziksang Blog garden ") // Assign a value to the confirmation box answer
if(answer) // Determine if you want to click OK
window.location ="http://www.cnblogs.com/Ziksang/" // Make sure the browser itself jumps
}
}
</script>
<button> Click the jump </button>
</body>
</html>
Here are some of the more common ways that js implements page jumping
1 species:
<script language="javascript" type="text/javascript">
window.location.href="login.jsp?backurl="+window.location.href;
</script>
The second:
<script language="javascript">
alert(" return ");
window.history.back(-1);
</script>
Third:
<script language="javascript">
window.navigate("top.jsp");
</script>
4 types:
<script language="JavaScript">
self.location='top.htm';
</script>
5 a:
<script language="javascript">
alert(" Illegal access! ");
top.location='xx.jsp';
</script>
Then I will introduce several ways that js uses popup window to realize page jump
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
Type 1: Pop up a selection box to jump to another page
<script language="javascript">
<!--
function logout(){
if (confirm(" Are you sure you want to cancel your identity? Yes - choose yes, no - Select cancel "))...{
window.location.href="/logout.asp?act=logout"
}
}
-->
</script>
<input type="button" onclick="logout()" value=" The cancellation "/>
Type 2: Pop-up prompt box to jump to another page
<script language="javascript">
<!--
function logout(){
alert(" Are you sure you want to cancel your identity? ");
window.location.href="/logout.asp?act=logout"
}
-->
</script>
<input type="button" onclick="logout()" value=" The cancellation "/>
The page automatically jumps to another page
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
Just add one line of code to the page
<meta http-equiv="Refresh" content="5; url=http://www.codepub.com" />
Among them, the content = "5; url = http: / / www. codepub. com "in 5 say 5 seconds after the jump, can be directly set to 0
This code is used to jump to the page when the user logs in
The onClick = "windows open (" Submit. html")"
to
onClick="window.location.reload('Submit.html');"
window.open('Submit.html')