指定したパラメータの値を取得するための関数。
script.js
function getParam(val) {
var p = location.search;
var v = '(?:(?:^|.*\s*)' + val + '\s*\=\s*([^&]*).*$)|^.*$';
return p.replace(new RegExp(v), '$1');
}
alert(getParam('hoge'));
More than 3 years have passed since last update.
指定したパラメータの値を取得するための関数。
function getParam(val) {
var p = location.search;
var v = '(?:(?:^|.*\s*)' + val + '\s*\=\s*([^&]*).*$)|^.*$';
return p.replace(new RegExp(v), '$1');
}
alert(getParam('hoge'));
Register as a new user and use Qiita more conveniently