JavaScript
[JS] URL 파라미터 값 추출하기
민돌v
2021. 12. 3. 00:31
let url_list = window.location.href.split('/')
const id = url_list[url_list.length - 1].replace(/[^0-9.]/g, '')
url에서 추출
getParm 정규식 추출
?name=??
function getParam(name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}