"window.location.href"、"location.href"是本页面跳转.
"parent.location.href" 是上一层页面跳转.
"top.location.href" 是最外层的页面跳转.
举例说明:
    如果A,B,C,D都是html,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页面跳转
如果D页面中有form的话,
    <form>:  form提交后D页面跳转
    <form target="_blank">:  form提交后弹出新页面
    <form target="_parent">:  form提交后C页面跳转
    <form target="_top"> :  form提交后A页面跳转

如果访问的是iframe里面的页面,重新加载最外层的页面

 
<html>
<head>
<title></title>
<script language="javascript">
function escapeFrame(){
if (window.top.location.href != window.location.href) {
window.top.location.reload();
}
}
</script>
</head> <body onload="escapeFrame()">
<iframe src="b.html" ></iframe>
</body>
</html>

window.top.location.href 和 window.location.href 的区别的更多相关文章

  1. 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法

    location.href 和 window.location.href 区别: 1.location.href 可以直接跳转其他地址(不属于本项目) 也可以跳转本项目中的 2.window.loca ...

  2. window.top.location.href 和 window.location.href 的区别

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

  3. window.location.href和window.top.location.href的区别

    if (window.location.href == window.top.location.href) {     window.top.location.href = "/index. ...

  4. window.location.href和window.open的几种用法和区别

    使用js的同学一定知道js的location.href的作用是什么,但是在js中关于location.href的用法究竟有哪几种,究竟有哪些区别,估计很多人都不知道了. 一.location.href ...

  5. window.location和window.location.href和document.location的关系

    1,首先来区分window.location和window.location.href. window.location.href是一个字符串. 而window.location是一个对象,包含属性有 ...

  6. window.location.href 和 window.location.replace 的区别

    window.location.href  和  window.location.replace 的区别 1.window.location.href=“url”:改变url地址: 2.window. ...

  7. window.location.Reload()和window.location.href 区别

    首先介绍两个方法的语法: reload 方法,该方法强迫浏览器刷新当前页面.语法:location.reload([bForceGet])参数: bForceGet, 可选参数, 默认为 false, ...

  8. window.location.href 与 window.loaction.replace区别

    window.location.href和window.location.replace的区别 1.window.location.href=“url”:改变url地址: 2.window.locat ...

  9. window.location.href和document.location.href、document.URL的区别

    1.document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个documen ...

随机推荐

  1. QDialog QMainwindow QWidget QFrame不同时候用法.

    继承关系:在Qt中所有的类都有一个共同的基类QObject ,QWidget直接继承与QPaintDevice类,QDialog.QMainWindow.QFrame直接继承QWidget 类.   ...

  2. python命名空间

    在"python之禅"那几句话中有一句:namespace is a good thing. python对于命名空间的处理非常简单,下面的内容不一定真实,完全是我根据现象推测出来 ...

  3. 【日常操作记录】Asp.Net Core 的一些基本操作或属性

    用于记录在项目中使用到的方法.属性.操作,持续更新中 静态文件的使用 在项目中静态文件的使用需要在Startup中的Configure方法中增加: //使用静态文件 app.UseStaticFile ...

  4. c# String.Join 和 Distinct 方法 去除字符串中重复字符

    1.在写程序中经常操作字符串,需要去重,以前我的用方式利用List集合和 contains去重复数据代码如下: string test="123,123,32,125,68,9565,432 ...

  5. C#事务

    看了很多关于事务的概念,还是觉得维基百科上说的最好: 数据库事务(简称:事务)是数据库管理系统执行过程中的一个逻辑单位,由一个有限的数据库操作序列构成. 一个数据库事务通常包含了一个序列的对数据库的读 ...

  6. Python 【第六章】:Python操作 RabbitMQ、Redis、Memcache、SQLAlchemy

    Memcached Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度 ...

  7. Javascript数值转换(string,int,json)

    数值: 在JavaScript中,数值转换一般有三种方式: 一.Number(param)函数:param可以用于任何数据类型 1.1 param是Boolean值,true和false分别转换为1和 ...

  8. float 对整形的取余运算

    取余是针对整形的,但是有时候一些特殊需求,我们需要 float 型对整形取下余数.比如,将角度化到 0- 360 范围内. 今天看到 lua 的实现方式: a % b == a - math.floo ...

  9. js数组方法

    数组方法清空数组1: arr.length=02: arr=[]arr.push()//往数组最后一个添加元素,会待会一个返回值,就是新的数组长度arr.unshift()//往数组的第一个添加元素, ...

  10. <<编程之美>>1.2读后有感

    问题提出 中国象棋的"将","帅"问题,他俩不能在一条直线上.求出他们的合法位置,并且只能用一个变量. 分析 一头雾水,不明所以.往下看了下,感觉像是程序员为难 ...