Home > Web Front-end > JS Tutorial > body text

How to get the value of URL parameter in javascript?

零下一度
Release: 2017-06-25 09:12:20
Original
1245 people have browsed it
function getUrlParameter(strParame){var args = new Object( );var query = location.search.substring(1);var pairs = query.split("&");for(var i = 0; i < pairs.length; i++) {var pos = pairs[i].indexOf('=');if (pos == -1) continue;var argname = pairs[i].substring(0,pos);var value = pairs[i].substring(pos+1);
            value = decodeURIComponent(value);
            args[argname] = value;
        }return args[strParame];
    }var id=getUrlParameter("id");var key=getUrlParameter("key");
    console.log(id);
    console.log(key);
Copy after login

The above is the detailed content of How to get the value of URL parameter in javascript?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template