Recently, a friend has been asking questions about css and JS when revising a website. Today, this friend asked me again about the link to the revised website, because the original website URLs are directly linked, and cannot be accessed after the revision, this will cause a loss to the website and a lot of traffic will disappear. If you use JS to turn around, how nice it is! This idea is good, so I told my friends that I needed an html page to pass parameters, so I used JavaScript code to get url parameters, retrieve the url parameter of a js and change the Website access address funciton to an instance:
URL type after redirection:Http://www.bkjia.com/url.htm? Url = http://www.liehuo.org
JS Code:
<Script language = "javascript" type = "text/javascript">
// Js obtains the function of the url parameter
Function request (paras ){
Var url = location. href;
Var paraString = url. substring (url. indexOf ("? ") + 1, url. length). split ("&");
Var paraObj = {}
For (I = 0; j = paraString [I]; I ++ ){
ParaObj [j. substring (0, j. indexOf ("="). toLowerCase ()] = j. substring (j. indexOf
("=") + 1, j. length );
}
Var returnValue = paraObj [paras. toLowerCase ()];
If (typeof (returnValue) = "undefined "){
Return "";
} Else {
Return returnValue;
}
}
Var theurl
Theurl = request ("url ");
If (theurl! = ''){
Location = theurl
}
</Script> |