---restore content to begin---
1.location.href .....
(1) self.loction.href= "Http://www.cnblogs.com/url"
Window.location.href= "Http://www.cnblogs.com/url" all two usages are the same as opening the URL page on the current page
(2) this.location.href= "Http://www.cnblogs.com/url" current page open URL
(3) parent.location.href= "Http://www.cnblogs.com/url" opens a new page on the parent page, and if a frame is customized on the page, then the parent self top can be changed to the name of the custom frame. The effect is to open the URL address in the frame window
(4) top.location.href= "Http://www.cnblogs.com/url" opens a new page on the top level page
2. About refreshing the page
(1) Window.location.href=http://www.cnblogs.com/nana-share/p/window.location.href
(2) Window.location.Reload ()
is to refresh the current page. The difference is whether the data is submitted. When there is a submission, window.location.Reload () prompts for submission, window.location.href=http://www.cnblogs.com/nana-share/p/ Window.location.href, the data is submitted to the specified URL
3.
(1) The first paragraph is actually in use
function Geturlparameter (name)
{2 3 return
decodeuricomponent (new RegExp) (' [? | +] ' + name + ' = ' + ' ([^&;] +?) (&|#|;| $). EXEC (Location.search) | | [, ""]) [1].replace (/\+/g, '%20 ')] | | Null Constructs a regular expression object containing the target parameter 4 5}
//Get the parameter 2
function Geturlparam (name)
{3
var reg = new RegExp (^|&) in the URL + name + "= ([^&]*) (&|$)"); Constructs a regular expression object containing the target parameter 4
var r = window.location.search.substr (1). Match (reg);//Match target parameter 5
if (R!= null) return Unescape (r[2]); return null; Return parameter value 6
}
For example, like getting the following linked mailbox
Http://agent/index.php/home/login/getpwd_check_email?code=824790&to=1321136493@qq.com
var mail = geturlparameter (' to ');
---Recovery content is over---
Next look at the JS operation URL Code
The code is very simple, the main idea is to parse the URL parameters to JS object, and then do add, delete, change, check the operation is very convenient ~, take notes here.
var lg= (function (LG) {var objurl=function (URL) {this.ourl=url| |
Window.location.href;
This.href= ""; the previous section This.params={};//url parameter Object this.jing= "";//#及后面部分 this.init (); }//Parse URL, get? Before saving this.href, parameter resolves to this.params object, #号及后面存入this. Jing objurl.prototype.init=function () {var str=this.ourl
;
var index=str.indexof ("#");
if (index>0) {this.jing=str.substr (index);
Str=str.substring (0,index);
} index=str.indexof ("?");
if (index>0) {this.href=str.substring (0,index);
Str=str.substr (index+1);
var parts=str.split ("&");
for (Var i=0;i<parts.length;i++) {var kv=parts[i].split ("=");
THIS.PARAMS[KV[0]]=KV[1];
}} else{This.href=this.ourl;
this.params={};
}//Only modifies This.params objurl.prototype.set=function (key,val) {this.params[key]=val;
}//Just set This.params objurl.prototype.remove=function (key) {this.params[key]=undefined;
///Based on the three-part URL after the operation Objurl.prototype.url=function () {var strurl=this.href; var objps=[];//here is organized with arrays, then join operations for (var k in this.params) {if (this.params[k)) {Objps.push (k + "=" +this.par
Ams[k]); } if (objps.length>0) {strurl+= "?"
+objps.join ("&");
} if (this.jing.length>0) {strurl+=this.jing;
return strurl;
//Get parameter Value Objurl.prototype.get=function (key) {return this.params[key]; } LG.
Url=objurl;
return LG; } (Lg| | {}));
LG is just my personal common JS namespace, without him. Call:
var myurl=new LG. URL ("Http://www.baidu.com?a=1");
Myurl.set ("B", "Hello"); Added B=hello
alert (Myurl.url ());
Myurl.remove ("B"); Delete the B
alert (Myurl.get ("a")),//Take the value of parameter A, where you get 1
myurl.set ("a", 23);//Modify the value of a to
alert (Myurl.url ());