location方式跳转

location方式的跳转需要在js中进行调用,通过调用它下面的href属性完成跳转,

window.location.href=“www.tstingmi.com/”:
window.location.replace

释义:将地址替换成新url,缓存在历史里,不能通过“前进”和“后 退”来访问已经被替换的URL。

使用方法:

window.location.replace(“www.tstingmi.com”):
window.location.reload

释义:强制刷新页面,重新请求。

使用方法:

window.location.reload(“www.tstingmi.com”):

a标签直接跳转

1

<a href="http://baidu.com">百度一下</a>

通过javascript中实现跳转

1

2

3

4

5

6

// 直接跳转

window.location.href='index.html';

// 定时跳转

setTimeout("javascript:location.href='index.html'", 5000);

其实两种方式是类似的,只是有的在javascript中写的跳转,另一种直接从html中写跳转

<button id="load" οnclick="window.location.reload('/html/index.html')">跳转</button>

html跳转上一页的方式

window.history.go(-1);或者window.history.back(-1);

在html中写

1

2

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

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

在javascript中写跳转上一页

1

2

3

4

5

6

7

8

<div id="btn">按钮</div>

<script type="text/javascript">

    var wrong = document.getElementById('btn');

    wrong.onclick = function {

window.history.go(-1);//返回上一页

window.history.back(-1);//返回上一页

   }

</script>

refresh方式跳转

refresh方式的跳转直接在head的meta标签里面添加就可以了,通过url设置跳转路径。

<metahttp-equiv="refresh"content="3;url=https://www.tstingmi.com">

如果refresh中不指定url,则是本页面刷新。

www.tstingmi.com 提供内容。