var url_string = "http://www.example.com/t.html?a=1&b=3&c=m2-m3-m4-m5"; //window.location.href var url = new URL(url_string); var c = url.searchParams.get("c"); console.log(c);
// https://testsite.com/users?page=10&pagesize=25&order=asc const urlParams = new URLSearchParams(window.location.search); const pageSize = urlParams.get('pageSize');
const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); const code = urlParams.get('code')
function getUrlParameter(name) { name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); var results = regex.exec(location.search); return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); };
www.test.com/t.html?a=1&b=3&c=m2-m3-m4-m5