Is there a javascript solution to read the url,create a string from it, and build a if statement based on the results? Does anyone know of a tutorial or can provide me with some tips of how to accomplish this.
To be more specific I am trying to do this based on a search result. So.. for example the url is something like:
http://www.site.com/catalogsearch/result?q=asdf&kw=asdf&x=0&y=0
and working off of Daniels response I am trying this with no luck:
if (window.location.search ==='?q=asdf') {
alert("You searched for asdf");
}
You can get the URL, or parts for it, using the
window.locationobject.For example, consider the following URL:
These are the standard properties of the
window.locationobject, and the value you would get for the above URL:For example, if you want to check the pathname, you could do the following: