---恢复内容开始---
(1)self.loction.href=""
window.location.href="" 以上两个用法相同均为在当前页面打开URL页面
(2)this.location.href="" 当前页面打开URL
(3) parent.location.href="" 在父页面打开新页面,如果页面中自定义了frame,那么可将parent self top换为自定义frame的名称,效果是在frame窗口打开URL地址
(4) top.location.href="" 在顶层页面打开新页面
(1)window.location.href=http://www.cnblogs.com/nana-share/p/window.location.href
(2)window.location.Reload()
都是刷新当前页面。区别在于是否有提交数据。当有提交数据时,window.location.Reload()会提示是否提交,window.location.href=http://www.cnblogs.com/nana-share/p/window.location.href;则是向指定的url提交数据
(1)第一段为实际在用的
例如像获取下面链接的邮箱 var mail = getURLParameter('to');
---恢复内容结束--- 下面再来看一下js操作url的代码 代码很简单,主要一个思路是把url参数解析为js对象,再做增、删、改、查操作就很方便了~,这里做笔记。 原文地址:https://www.jb51.cc/js/51943.html 版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。
function getUrlParam(name)
{3
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象4
var r = window.location.search.substr(1).match(reg); //匹配目标参数5
if (r != null) return unescape(r[2]); return null; //返回参数值6
}