星空网 > 软件开发 > Java

js对URL的相关操作集锦

---恢复内容开始---

1.location.href.....

(1)self.loction.href="http://www.cnblogs.com//url"

       window.location.href="http://www.cnblogs.com//url"    以上两个用法相同均为在当前页面打开URL页面

(2)this.location.href="http://www.cnblogs.com//url"    当前页面打开URL

(3) parent.location.href="http://www.cnblogs.com//url"   在父页面打开新页面,如果页面中自定义了frame,那么可将parent self top换为自定义frame的名称,效果是在frame窗口打开url地址

(4) top.location.href="http://www.cnblogs.com//url"   在顶层页面打开新页面

2. 关于刷新页面

 (1)window.location.href=window.location.href

 (2)window.location.Reload()

    都是刷新当前页面。区别在于是否有提交数据。当有提交数据时,window.location.Reload()会提示是否提交,window.location.href=window.location.href;则是向指定的url提交数据

3.

 (1)第一段为实际在用的

1 function getURLParameter(name) {2 3      return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null; //构造一个含有目标参数的正则表达式对象4 5   }


1 //获取url中的参数2     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     }

  例如像获取下面链接的邮箱

  http://agent/index.php/Home/Login/getpwd_check_email?code=824790&to=1321136493@qq.com

   

var mail = getURLParameter('to');

 

---恢复内容结束---




原标题:js对URL的相关操作集锦

关键词:JS

JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

黑五、网一表现不如意?稳住!这样做还有爆单的机会!:https://www.kjdsnews.com/a/701109.html
Shopify网站无法跳转Paypal,造成巨大单量损失。:https://www.kjdsnews.com/a/701110.html
亚马逊Best Seller Rank品类分析——野营帐篷(Camping Tents):https://www.kjdsnews.com/a/701111.html
过去一年,Shopee该站点的卖家数量增加逾一倍:https://www.kjdsnews.com/a/701112.html
亚马逊产品的定价策略及调价技巧:https://www.kjdsnews.com/a/701113.html
深耕跨境电商行业,你的核心优势究竟是什么?:https://www.kjdsnews.com/a/701114.html
长治婚庆女司仪和主持人:https://www.vstour.cn/a/366176.html
北京丰台区水上乐园哪家好玩?:https://www.vstour.cn/a/366177.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流