"; 2. In JavaScript, you can use the href attribute of the location object to jump, with the syntax "window.location. href=page address"."/> "; 2. In JavaScript, you can use the href attribute of the location object to jump, with the syntax "window.location. href=page address".">

Home  >  Article  >  Web Front-end  >  How to jump to the page using html/JavaScript

How to jump to the page using html/JavaScript

青灯夜游
青灯夜游Original
2021-04-12 17:54:143294browse

How to jump to the page: 1. In HTML, you can use the meta tag to jump, with the syntax ""; 2. In JavaScript, you can use the href attribute of the location object to jump, with the syntax "window. location.href=Page address".

How to jump to the page using html/JavaScript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

html/JavaScript to achieve page jump

1. Use meta to jump in html. You can set the jump time and page through meta

<head>
    <!--只是刷新不跳转到其他页面 -->
    <meta http-equiv="refresh" content="5">
    <!--定时转到其他页面 -->
    <meta http-equiv="refresh" content="5;url=index.html"> 
</head>

2. Jump to the previous page through javascript

1 // 直接跳转
2 window.location.href='index.html';
3 // 定时跳转
4 setTimeout("javascript:location.href='index.html'", 5000);

html

window.history.go(-1); or window.history .back(-1);

<script type="text/javascript">
    var wrong = document.getElementById('btn');
    wrong.onclick = function() { 
    window.history.go(-1);//返回上一页
     window.history.back(-1);//返回上一页
   }
</script>

Write in html

<a href=”#” onClick=”JavaScript :history.back(1);”>返回上一页</a>
<a href=”#” onClick=”javascript :history.Go(-1);”>返回上一页</a>

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of How to jump to the page using html/JavaScript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn