在线客服与您一对一交流
当前位置: 主页 > 行业新闻 > IT技术 >

js刷新页面location.reload()用法介绍

在js中要实现刷新页面的方法有很多种,下面我来介绍其中的一种办法来刷新页面,在js中有一个location.reload()函数,它就可以实现我们想要的功能。

如果要刷新当前页面非常的简单

JS实现刷新iframe的方法

用iframe的name属性定位

onclick="document.frames('ifrmname').location.reload()">

onclick="document.all.ifrmname.document.location.reload()">

首先,定义一个iframe

aa.htm内容如下:

 
function aa() { 
//parent.location.replace(parent.location.href);//服务器端重新创建页面 
parent.document.location.reload();//相当于F5 
//window.location.href(parent.location.href);//iframe内容重定向 
}

小提示

window.location.reload;刷新时如果提交数据的动作,则会出现讨厌的对话框!

解决办法

window.location.href=window.location.href; 
window.location.reload; 

同理,如果是刷新父窗口,应该这样写:

window.opener.location.href=window.opener.location.href; 
window.opener.location.reload(); 

这种写法就不出现那讨厌的对话框啦!

相关文章:

  • 公司:新浦金350vip!
  • 联系人:张经理
  • 手机/微信:
  • Q Q: 点击这里给我发消息
  • 地址:西安市雁塔区唐延南路11号逸翠园i都会