Is there any method to get the URL without query string?
I have a URL like http://localhost/dms/mduserSecurity/UIL/index.php?menu=true&submenu=true&pcode=1235.
I want to get the URL without the query string: http://localhost/dms/mduserSecurity/UIL/index.php.
var url = [location.protocol, '//', location.host, location.pathname].join('');
var url = window.location.origin + window.location.pathname;
If you also want to remove hash, try this one:
document.location.protocol + '//' + document.location.host + document.location.pathname;
.host rather than
.hostname so that the port gets included too, if necessary)