原生js和jquery框架下的页面刷新和页面跳转

来源:互联网 发布:python 调用caffe模型 编辑:程序博客网 时间:2024/06/06 00:48

一、html方式跳转

1.页面自动刷新:把如下代码加入<head>区域中
<meta http-equiv="refresh" content="20">
其中20指每隔20秒刷新一次页面

2.页面自动跳转:把如下代码加入<head>区域中
<meta http-equiv="refresh"content="20;url=http://www.wyxg.com">
其中20指隔20秒后跳转到http://www.wyxg.com页面

 

二、原生js

window.location.href="http://www.test.com/1.php"; 

window.navigate("http://www.test.com/2.php ");

window.location.replace("http://test.baidu.com//3.php "); 

从用户界面来看是没有什么区别的,但是当3.php页面有一个"返回"按钮,调用window.history.Go(-1);wondow.history.back();方法的时候,一点这个返回按钮就要返回2.php页面的话,区别就出来了,当用 window.location.replace("3.php");连到3.php页面的话,3.php页面中的调用 window.history.go(-1);wondow.history.back();方法是不好用的,会返回到1.php

self.location='target.aspx';  

top.location='target.aspx';

window.history.back(-1); 

 

三、jquery框架

location.href = " http://www.test.com/4.php?page="+pn;

window.open("http://www.test.com/4.php?page="+pn);

 

原生js其他总结

一、跳转页面    

1. location.href 和 window.open,但是location.href只能在本页面打开新页面,但是window.open可以

window.open("http://www.baidu.com/", "_search");//在一个浏览器窗口打开百度

window.open("http://www.baidu.com/", "_self");//在一个原有窗口打开百度

window.open("http://www.baidu.com/", "_blank");//在一个新的窗口打开百度

 

3. 打开一个新的窗口,并命名为"hello"

window.open("", "hello");

             

1. 返回上一页: history.go(-1);  history.back()

例子:history.go(-1), 返回两个页面: history.go(-2);


2. 返回下一页:window.history.forward()


3. 返回指定页:window.history.go(返回第几页,也可以使用访问过的URL);

 

 

二、刷新页面

1   history.go(0)
2    location.reload()
3    location=location
4    location.assign(location)
5    document.execCommand('Refresh')
6    window.navigate(location)
7    location.replace(location)
8    document.URL=location.href

 

http://blog.csdn.net/mazhaojuan/article/details/9099913

 

 ajax动态为<a> href 赋值,总是不执行跳转的原因

原创粉丝点击