I am using the following code to change the display of elements. I use jQuery and my problem is that it only checks URL in the begging and in the next change of URL it is not working.
<script>
alert(window.location.href);
if (window.location.href.indexOf("drinks=spirits") > -1) {
alert("Hello! I am an alert box!!");
}
</script>
For example: I follow this order:
1- On the first visit, the URL is HTTP://example.com/drinks=spirits and it works.
2- Then I click on a filter, since I use ajax without reloading the page the URL changes to HTTP://example.com/drinks=spirits&price=less_10.
3- Then again when I remove the filter (again the page is not reloaded, it only removes the query) and the URL will be HTTP://example.com/drinks=spirits. Now the alert does not appear!
I am looking for a solution that shows the alert anytime users redirects to the HTTP://example.com/drinks=spirits