window.location.href 用法总结
想做好前端,这几种用法一定要了解;
在做网页前端的时候会经常用到JavaScript其中window.location.href用得非常多;
其中最常用的有windows.location.href=”/url”在当前页面打开URL页面;
其实和A标签超链接里面的target=”_self” 意思是一样的,只不过一个是HTML写法,一个是JavaScript的写法而已;
javascript中的location.href有很多种用法,主要如下。
当前页面打开URL页面
self.location.href=”/url”
当前页面打开URL页面
location.href=”/url”
当前页面打开URL页面,前面三个用法相同
windows.location.href=”/url
当前页面打开URL页面
this.location.href=”/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 用法总结的更多相关文章
- window.location.href用法与a标签的比较
1.在使用这两种方法进行页面的跳转时,这两种方法都能够有效的实现该功能 但是其原理不尽相同 第一:window.location.href()方法必须书写在js中 <html> <h ...
- [转载]window.location.href的用法(动态输出跳转)
无论在静态页面还是动态输出页面中window.location.href都是不错的用了跳转的实现方案 javascript中的location.href有很多种用法,主要如下. self.loca ...
- 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法
"window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...
- window.open和window.location.href的几种用法
windows.open("URL","窗口名称","窗口外观设定"); <A href="javascript:windo ...
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
location.href 和 window.location.href 区别: 1.location.href 可以直接跳转其他地址(不属于本项目) 也可以跳转本项目中的 2.window.loca ...
- window.location.href的用法
在写ASP.Net程序的时候,我们经常遇到跳转页面的问题,我们经常使用Response.Redirect 做ASP.NET框架页跳转,如果客户要在跳转的时候使用提示,这个就不灵光了,如: Respon ...
- 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法与区别(跳出iframe方法)
"window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...
- 关于js中window.location.href,location.href,parent.location.href,top.location.href用法
"window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...
- window.location.href和window.open的几种用法和区别
使用js的同学一定知道js的location.href的作用是什么,但是在js中关于location.href的用法究竟有哪几种,究竟有哪些区别,估计很多人都不知道了. 一.location.href ...
- window.location.assign和window.location.href区别
window.location.assign和window.location.href区别 window.location.assign(url)和window.location.href=url实现 ...
随机推荐
- Educational Codeforces Round 141 解题报告
Educational Codeforces Round 141 解题报告 \(\text{By DaiRuiChen007}\) \(\text{Contest Link}\) A. Make it ...
- Ansible 学习笔记 - 定位主机和组的模式
中英文对照表 英文 中文 备注 host 主机 group (主机)组 pattern 模式 ad hoc 特别命令 playbook 剧本 Ansible 专有名词,一段复杂的编排 inventor ...
- 算法学习笔记(9): 中国剩余定理(CRT)以及其扩展(EXCRT)
扩展中国剩余定理 讲解扩展之前,我们先叙述一下普通的中国剩余定理 中国剩余定理 中国剩余定理通过一种非常精巧的构造求出了一个可行解 但是毕竟是构造,所以相对较复杂 \[\begin{cases} x ...
- 案例:用ajax get方法 查询用户列表
html文件 <body> <div id="d1"></div> <button onclick="getlist()&q ...
- Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.1.0
maven package 异常,今天打包springboot项目时碰到的问题. Failed to execute goal org.apache.maven.plugins:maven-resou ...
- Rust 闭包与生命周期
- BAL数据集详解
详细格式:https://grail.cs.washington.edu/projects/bal/ Bundle Adjustment in the Large Recent work in Str ...
- javaEE(多线程、线程通信、线程安全、线程池、线程池工具)
多线程 多线程的创建 Thread类的方法 线程安全.线程同步 线程通信.线程池 定时器.线程状态.. Thread类 java是通过java.lang.Thread类来代表线程的 按照面向对象的思想 ...
- vue2安装sass 预编译
步骤一: 安装node-sass.sass-loader.style-loader npm i node-sass sass-loader style-loader --save-dev 步骤二: 打 ...
- TCP/IP协议(8): ICMP(Internet Control Message Protocol) 协议 ——诊断和控制 IP 协议层
TCP/IP协议(8): ICMP(Internet Control Message Protocol) 协议 --诊断和控制 IP 协议层 关于网际控制报文协议(Internet Control M ...