博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
js 刷新页面window.location.reload();
阅读量:2094 次
发布时间:2019-04-29

本文共 1416 字,大约阅读时间需要 4 分钟。

Javascript刷新页面的几种方法:

  history.go(0)
  window.location.reload()

    window.location.reload(true) 

  location=location
  location.assign(location)
  document.execCommand(''Refresh'')
  window.navigate(location)
  location.replace(location)
  document.URL=location.href

 

Frame框架:

frame.html:

<framesetrows="50%,50%">

      <frame name=top src="top.html">
      <frame name=bottomsrc="bottom.html">
   </frameset>

七种语句:

语句1.window.parent.frames[1].location.reload();

    语句2.window.parent.frames.bottom.location.reload();
    语句3.window.parent.frames["bottom"].location.reload();
    语句4.window.parent.frames.item(1).location.reload();
    语句5.window.parent.frames.item(''bottom'').location.reload();
    语句6.window.parent.bottom.location.reload();
    语句7.window.parent[''bottom''].location.reload();

 

top.html 页面的代码如下:

<input type=button value="刷新1"onclick="window.parent.frames[1].location.reload()">

 

bottom.html页面:

<bodyonload="alert(''我被加载了!'')">

     <h1>This is the content inbottom.html.</h1>
   </body>

 

1.window指代的是当前页面,例如对于此例它指的是top.html页面。

   2.parent指的是当前页面的父页面,也就是包含它的框架页面。例如对于此例它指的是frame.html。
   3.frames是window对象,是一个数组。代表着该框架内所有子页面。
   4.item是方法。返回数组里面的元素。
   5.如果子页面也是个框架页面,里面还是其它的子页面,那么上面的有些方法可能不行。

 

如果想关闭窗口时刷新或者想开窗时刷新的话,在<body>中调用以下语句即可。

<bodyonload="opener.location.reload()">开窗时刷新

   <bodyonUnload="opener.location.reload()">关闭时刷新

 

//子窗口刷新父窗口

<scriptlanguage=JavaScript>
   self.opener.location.reload();
</script>
( 或 <ahref="javascript:opener.location.reload()">刷新</a>  )

转载地址:http://iluhf.baihongyu.com/

你可能感兴趣的文章
Sublime text3快捷键演示
查看>>
sublime text3 快捷键修改
查看>>
硬盘的接口、协议
查看>>
VLAN与子网划分区别
查看>>
Cisco Packet Tracer教程
查看>>
02. 交换机的基本配置和管理
查看>>
03. 交换机的Telnet远程登陆配置
查看>>
微信小程序-调用-腾讯视频-解决方案
查看>>
phpStudy安装yaf扩展
查看>>
密码 加密 加盐 常用操作记录
查看>>
TP 分页后,调用指定页。
查看>>
Oracle数据库中的(+)连接
查看>>
java-oracle中几十个实用的PL/SQL
查看>>
PLSQL常用方法汇总
查看>>
几个基本的 Sql Plus 命令 和 例子
查看>>
PLSQL单行函数和组函数详解
查看>>
Oracle PL/SQL语言初级教程之异常处理
查看>>
Oracle PL/SQL语言初级教程之游标
查看>>
Oracle PL/SQL语言初级教程之操作和控制语言
查看>>
Oracle PL/SQL语言初级教程之过程和函数
查看>>