js中location.href的用法
Javascript中的location.href有很多种用法,主要如下:
  self.location.href="/url" 当前页面打开URL页面
  ocation.href="/url" 当前页面打开URL页面
  windows.location.href="/url" 当前页面打开URL页面,前面三个用法相同。
  this.location.href="/url" 当前页面打开URL页面
  parent.location.href="/url" 在父页面打开新页面
  top.location.href="/url" 在顶层页面打开新页面
如果页面中自定义了frame,那么可将parent self top换为自定义frame的名称,效果是在frame窗口打开url地址
此外,window.location.href=window.location.href;和window.location.Reload()和都是刷新当前页面。区别在于是否有提交数据。当有提交数据时,window.location.Reload()会提示是否提交,window.location.href=window.location.href;则是向指定的url提交数据。
"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页面跳转
如果D页面中有form的话,
<form>: form提交后D页面跳转
<form target="_blank">: form提交后弹出新页面
<form target="_parent">: form提交后C页面跳转
<form target="_top"> : form提交后A页面跳转
 
关于页面刷新,D 页面中这样写:
"parent.location.reload();": C页面刷新 (当然,也可以使用子窗口的 opener 对象来获得父窗口的对象:window.opener.document.location.reload(); )
"top.location.reload();": A页面刷新
js中location.href的用法的更多相关文章
- 关于js中iframe 中 location.href的用法
		关于js中"window.location.href"."location.href"."parent.location.href".&qu ... 
- JS里设定延时:js中SetInterval与setTimeout用法
		js中SetInterval与setTimeout用法 JS里设定延时: 使用SetInterval和设定延时函数setTimeout 很类似.setTimeout 运用在延迟一段时间,再进行某项操 ... 
- 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法
		"window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ... 
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
		location.href 和 window.location.href 区别: 1.location.href 可以直接跳转其他地址(不属于本项目) 也可以跳转本项目中的 2.window.loca ... 
- 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法与区别(跳出iframe方法)
		"window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ... 
- js location.href 的用法
		self.location.href="/url" 当前页面打开URL页面: this.location.href="/url" 当前页面打开URL页面: pa ... 
- [转载]window.location.href的用法(动态输出跳转)
		无论在静态页面还是动态输出页面中window.location.href都是不错的用了跳转的实现方案 javascript中的location.href有很多种用法,主要如下. self.loca ... 
- window.location.href的用法
		在写ASP.Net程序的时候,我们经常遇到跳转页面的问题,我们经常使用Response.Redirect 做ASP.NET框架页跳转,如果客户要在跳转的时候使用提示,这个就不灵光了,如: Respon ... 
- location.href的用法
		*.location.href 用法: top.location.href=”url” 在顶层页面打开url(跳出框架) self.location.href=”url” ... 
随机推荐
- JavaScript对象字面量
			<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ... 
- ASP.NET MVC5利用EF,反向自动生成数据库
			1.在Model类里面,写好相应的属性. using System; using System.Collections.Generic; using System.Linq; using System ... 
- Use the PDFs below or the HTML contents to the left to install and configure P6 EPPM and its additional components.
			Welcome to Your Documentation Use the PDFs below or the HTML contents to the left to install and c ... 
- Linq查询操作之Where筛选
			筛选操作where能够处理逻辑运算符组成的逻辑表达式.比如逻辑“与”,逻辑“或”,并从数据源中筛选数据,它和where子句的功能非常相似.Enumerable类的Where()原型如下: public ... 
- C#方法的六种参数,值参数、引用参数、输出参数、参数数组、命名参数、可选参数
			方法的参数有六种,分别是值参数.引用参数.输出参数.参数数组.命名参数.可选参数. 值参数 值参数是方法的默认类型,通过复制实参的值到形参的方式把数据传递到方法,方法被调用时,系统作两步操作: 在栈中 ... 
- HTML5的新特性
			HTML5 中的一些有趣的新特性: 用于绘画的 canvas 元素 用于媒介回放的 video 和 audio 元素 对本地离线存储的更好的支持 新的特殊内容元素,比如 article.footer. ... 
- 搭建spring的开发环境
			在eclipse中新建web项目,集成spring开发环境,把集成spring的过程描述如下, 1.从spring官网下载spring的jar包,我这里是spring4.1,下载的文件中包含了源码及文 ... 
- 中国快递包裹总量的预测-基于SARIMA模型
			code{white-space: pre;} pre:not([class]) { background-color: white; }if (window.hljs && docu ... 
- android.widget.RadioButton 单选按钮(转)
			大家好,我们今天这一节要介绍的是RadioGroup 的组事件.RadioGroup 可将各自不同的RadioButton ,设限于同一个Radio 按钮组,同一个RadioGroup 组里的按钮,只 ... 
- android studio :com.android.support:appcompat-v7:21.+ 报错
			android studio :com.android.support:appcompat-v7:21.+ 报错: 在project——>app——>build.gradle修改: app ... 
