I have this url:
csumb/index.php?page=consultanta
I try to compare 2 links but this code do the same thing if I change my link and I refresh the page.
var pathname = window.location.pathname;
var a = "csumb/index.php?page=consultanta";
if(pathname == a) {
$("body").html("rahat");
}
There’s multiple parts to
location(orwindow.location, to use the literal reference):https://packagist.org/search/?search_query%5Bquery%5D=symfony
Using
console.log(location)directly into the Chrome console, it gives the following properties (plus some other stuff):What you’re really after is:
The filename, if in the URL, will be in
location.pathname, soindex.phpwill not need to be added separately either.