我想要獲取以下id spa
以下代碼(傳參要加問好!!)code
function getUrlParam(id) { var regExp = new RegExp('([?]|&)' + id+ '=([^&]*)(&|$)'); var result = window.location.href.match(regExp); if (result) { return decodeURIComponent(result[2]); } else { return null; } } var id = getUrlParam("id"); alert(id);
效果:blog