Posted at

URLから特定のパラメータの値をとりだす

More than 5 years have passed since last update.

http://~~~~?code=●●●●●●

↑の●●●を取り出す。

slicePalamValue = function(url, key){

return url.split(key+"=")[1].split("&")[0];
}

var url = http://aaaaaaaaa.com/code=ABCDEFG
console.log(slicePalamValue(url,"code")); //ABCDEFG