JS实现iframe框架页面跳转和刷新

一、js方式的页面跳转

1.window.location.href方式

<script language="javascript" type="text/javascript">

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

</script>

2.window.navigate方式跳转 Firefox不支持

<script language="javascript">

window.navigate("top.jsp");

</script>

如果:top.jsp中有Iframe则,top.jsp在iframe中打开。(IE6测试过);

3.window.loction.replace方式实现页面跳转,注意跟第一种方式的区别

<script language="javascript">

window.location.replace("http://www.siteeasy.cn");

</script>

有3个jsp页面(a.jsp, b.jsp, c.jsp),进系统默认的是a.jsp ,当我进入b.jsp的时候, c.jsp里面用window.location.replace("c.jsp");与用window.location.href ("c.jsp");从用户界面来看是没有什么区别的,但是当c.jsp页面有一个"返回"按钮,调用window.history.go(-1); wondow.history.back();方法的时候,一点这个返回按钮就要返回b.jsp页面的话,区别就出来了,当用 window.location.replace("c.jsp");连到c.jsp页面的话,c.jsp页面中的调用 window.history.go(-1);wondow.history.back();方法是不好用的,会返回到a.jsp 。

4.self.location方式实现页面跳转,和下面的top.location有小小区别

<script language="JavaScript">

self.location='top.htm';

</script>

5.top.location

<script language="javascript">

top.location='xx.jsp';

</script>

6.不推荐这种方式跳转

<script language="javascript">

window.history.back(-1);

</script>

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

8.<a href="javascript:history.go(-1)">返回上一步</a>

9.<a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>

10.<a href="javascript:" onClick="window.open('http://hi.baidu.com/630270730','','height=500,width=611,scrollbars=yes,status=yes')">打开新窗口</a>

11..window.history.forward()返回下一页

12. window.history.go(返回第几页,也可以使用访问过的URL)

二、iframe中页面跳转

1.iframe页面跳转:

"window.location.href"、"location.href"是本页面跳转

"parent.location.href"是上一层页面跳转

"top.location.href"是最外层的页面跳转

例:如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写

"window.location.href"、"location.href":D页面跳转

"parent.location.href":C页面跳转

"top.location.href":A页面跳转

2.iframe中的target

如果D页面中有form的话,form提交后D页面跳转

<form target="_blank">:form提交后弹出新页面

<form target="_parent">:form提交后C页面跳转

<form target="_top"> :form提交后A页面跳转

三.iframe页面刷新

D 页面中这样写:"parent.location.reload();": C页面刷新

(当然,也可以使用子窗口的 opener 对象来获得父窗口的对象:window.opener.document.location.reload(); )

"top.location.reload();": A页面刷新

window.location.href = window.location.href 也可以实现页面刷新,它与reload的区别是:如果在reload之前想服务器提交过数据,那么执行reload会重新执行这个提交操作。 而window.location.href = window.location.href 则不会,因为它是重新进入页面。

//子窗口刷新父窗口

<script language=JavaScript>

self.opener.location.reload();

</script>

(或<a href="javascript:opener.location.reload()">刷新</a> )

//如何刷新另一个框架的页面用

<script language=JavaScript>

parent.另一FrameID.location.reload();

</script>

 

转发自:易软动力

20150311—html中iframe(转发)的更多相关文章

  1. Servlet中的转发

    public class OneServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServ ...

  2. vscode中iframe的使用

    vscode中iframe由于某种原因不支持本地页面,比如<iframe src ="index.html" width="300" height=&qu ...

  3. easyui 中iframe嵌套页面,大弹窗自适应居中的解决方法。$('#win').window()

    easyui 中iframe嵌套页面,大弹窗自适应居中的解决方法.$('#win').window() 以下是左边栏和头部外层遮罩显示和隐藏方法 /*外层 遮罩显示*/ function wrapMa ...

  4. easyui 中iframe嵌套页面,提示弹窗遮罩的解决方法,parent.$.messager.alert和parent.$.messager.confirm

    项目中用到easyui 布局,用到north,west,center三个区域,且在center中间区域嵌入iframe标签.在主内容区做一些小提示弹窗(例如删除前的弹窗提示确认)时,会遇到遮罩问题,由 ...

  5. ios中iframe的scroll滚动事件替代方法

    在公众号的开发中,遇到ios中iframe的scroll滚动事件失效,在此做下记录. 因为接口获取的数据必须放在iframe中展示,滚动到底部按钮变亮,如图: 代码如下: <!DOCTYPE h ...

  6. python selenium中iframe切换、window切换方法

    一.selenium中iframe切换方法: 方法一:switch_to.frame frame函数中提供了三种定位方法:by index, name, or webelement. driver.s ...

  7. IE浏览器中IFrame被加载两次问题的解决-sunziren

    本文为作者sunziren原创,首发博客园,转载请注明出处. 昨天遇到了一个问题,先上代码. var content = '<iframe src="www.baidu.com&quo ...

  8. jQuery中iframe的操作

    今天遇到一个问题:怎样实现点击一个按钮,在当前的页面上新增加一个小窗口,展示一个图片信息? 如图: 点击之前: 单击之后: 分析:要使新增的小窗口不影响父页面,我们这里采用iframe的框架的技术. ...

  9. 响应式web布局中iframe的自适应

    困境 在响应式布局中,我们应该小心对待iframe元素,iframe元素的width和height属性设置了其宽度和高度,但是当包含块的宽度或高度小于iframe的宽度或高度时,会出现iframe元素 ...

随机推荐

  1. oracle 11g 没有scott用户下emp的创建方法

    oracle 11g 安装后 没有scott 用户, 创建scott 用户后 使用select * from emp查询 emp表, 结果为 找不到行. 运行脚本 utlsample.sql 首先as ...

  2. GLSL实现Simple Displace Mapping 水仿真流体绘制 【转】

    http://blog.csdn.net/a3070173/archive/2008/11/20/3342062.aspx Dislace Mapping其实就是在顶点着色器中 对顶点进行置换偏移,经 ...

  3. SQL自增长的数据插入

    --子增长的插入 /*创建表*/ create table teacher ( id int identity(1,1) primary key not null, name varchar(20) ...

  4. Reservoir Sampling - 蓄水池抽样

    问题起源于编程珠玑Column 12中的题目10,其描述如下: How could you select one of n objects at random, where you see the o ...

  5. 史上最详细版!java文件打包成exe,在未配置安装JDK和未配置的电脑上运行--转载

    原文地址:http://funine.iteye.com/blog/2220359 (本文所有素材将在文章最后附上) 准备工具exe4j, converticon.com(用于制做.ico格式的图片) ...

  6. html 模板

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  7. iOS - UI - UITextView

    1.UITextView //因为继承于UIScrollView 拥有scrollView的所有属性和方法 //placeholder只有UITextField有,UITextView是没有的.(提示 ...

  8. oracle PL/SQL(procedure language/SQL)程序设计

    PL/SQL(procedure language/SQL)语言是Oracle对SQL语言的过程化扩充,是一个完整的编程语言.PL/SQL实现了过程化语句(如分支.循环等)与SQL语句的无缝连接,将过 ...

  9. [转]div 让文字或图片居中

    本文转自:http://qsfwy.iteye.com/blog/250206 在div 中让 文字或图片居中,请参考以下代码1: - - - - - - - - - - - - - - - - - ...

  10. Codeforces Round #197 (Div. 2) C,D两题

    开了个小号做,C题一开始看错范围,D题看了半小时才看懂,居然也升到了div1,囧. C - Xenia and Weights 给出一串字符串,第i位如果是1的话,表示有重量为i的砝码,如果有该种砝码 ...