ex. http://localhost:10201/page.html?id=whatever
js取得方式
var parseQueryString = function () { var str = window.location.search; var objURL = {}; str.replace( new RegExp("([^?=&]+)(=([^&]*))?", "g"), function ($0, $1, $2, $3) { objURL[$1] = $3; } ); return objURL; };
var params = parseQueryString(); console.log(params["id"]);
沒有留言:
張貼留言