Home >Web Front-end >JS Tutorial >JS implements reloading the current page

JS implements reloading the current page

高洛峰
高洛峰Original
2016-12-03 14:38:371371browse

[javascript] view plain copy print?
 
用JavaScript刷新上级页面和当前页面 
  
<script type="text/javascript"> 
  
window.parent.main.document.location.reload();//上级页面 
  
document.location.reload();//当前页面 
  
每个frame元素或者iframe元素就是一个框架,这个框架是一个窗口,在这个窗口中加载一个html文档.使用下面的几种方法都可以引用frame或iframe元素: 
  
window.frames[index] 
  
windows.frames["框架名"] 
  
windows.框架名 
  
如果想从框架所加载的网页中获取对父窗口的引用,那么就可以使用下面的方法: 
  
window.parent 
  
如果要对父窗口中某个框架的引用,那么就可以使用下面的方法: 
  
window.parent.框架名 
  
也可以使用下面的方法获取对父窗口的最顶端框架的引用: 
  
window.top 
  
一旦获得对框架的引用,就可以操控该框架对象. 
  
<frameset rows="29,*" frameborder="0" border="0" framespacing="0" cols="*"> 
<frame name="top" scrolling="NO" noresize src="top.html"> 
<frameset cols="20%,*" frameborder="0" border="0" framespacing="0" rows="*" scrolling="NO" name="mleft"> 
 <frame src="menu.html" frameborder=NO border="0" scrolling="NO" > 
 <frameset rows="20,100%,*" name="content" frameborder="1" framespacing="1" cols="*"> 
 <frame src="title.html" frameborder=0 noresize scrolling="NO" name="mtitle"> 
 <frame src="" frameborder=0 name="main" marginwidth="0" marginheight="0" scrolling="YES"> 
 <frame src="" frameborder=0 name="detail"> 
 </frameset> 
</frameset> 
</frameset> 
  
--------index.jsp 
  
<DIV CLASS="level2" ID=&#39;head6Child&#39;> 
<A href="orderlist.jsp" id=ttt target=main><LI>订单浏览</LI></a> 
</DIV> 
  
------------AdminTree.html 
  
<tr> 
 <td>ID</td> 
 <td>Username</td> 
 <td>Phone</td> 
 <td>Addr</td> 
 <td>Rdate</td> 
 <td>do_it</td> 
</tr> 
<% 
for(Iterator<User> it=users.iterator();it.hasNext();){ 
 User u=it.next(); 
%> 
<tr> 
 <td><%=u.getId() %></td> 
 <td><%=u.getUsername() %></td> 
 <td><%=u.getPhone() %></td> 
 <td><%=u.getAddr()%></td> 
 <td><%=u.getRdate() %></td> 
 <td> 
 <a href="userdelete.jsp?id=<%=u.getId()%>" target="detail">delete</a> 
 </td> 
</tr> 
  
----------userlist.jsp 
  
<% 
int id=Integer.parseInt(request.getParameter("id")); 
UserManager.deleteUser(id); 
%> 
  
 <body> 
 delete successfully!!!! <br> 
<script type="text/javascript"> 
<!-- 
 window.parent.main.document.location.reload(); 
 --> 
</script> 
</body> 
  
--------userdelete.jsp


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