I want to get parameter from url. Following is my url. I wnt to get "uid" parameter from my url.
http://localhost:8080/mydemoproject/#/tables/view?uid=71
I want to get parameter from url. Following is my url. I wnt to get "uid" parameter from my url.
http://localhost:8080/mydemoproject/#/tables/view?uid=71
Try it:
window.location.href.split("=")[1]
Try solving these problems with RegEx
let myURL = window.location.href; // "http://localhost:8080/mydemoproject/#/tables/view?uid=71"
let myRegexp = /uid=(\d*)/i;
let match = myRegexp.exec(myURL);
if (match !== null) {
console.log(match[1]); // 71
}
A condensed version would look like this
let match = /uid=(\d*)/i.exec(window.location.href);
let uidValue = (match !== null ? match[1] : undefined);
console.log(uidValue); // 71
On page load call the function "get_param('uid');
"
And paste this code into your document.
<script type= "text/javascript" >
function get_param(param) {
var vars = {};
window.location.href.replace(location.hash, '').replace(
/[?&]+([^=&]+)=?([^&]*)?/gi, // regexp
function (m, key, value) { // callback
vars[key] = value !== undefined ? value : '';
}
);
alert(vars[param]);
}
</script>