JS get URL parameter Using extended instance _javascript tips

Source: Internet
Author: User
Recent Web site revision, found that the site's ads are direct web site, if a turn, for the site's full-time will be better
Need an HTML page to pass parameters, so use a JS to get the URL parameters of the code, just a Funciton
Reference http://img.jb51.net/url.htm?url=http://www.baidu.com
Copy Code code as follows:

<script language= "javascript" type= "Text/javascript" >
JS gets 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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.