I have some jQuery code that is on every web page of the site (in the head element).
What selector syntax can I use to tell jQuery that a certain function should only ru
I prefer to do stuff like this in whatever language you are writing your app in. Your layout/template/whatever that is serving up your html could simply output a true/false to a javascript variable
if ($page = '/foo/bar.html/') {
echo 'baz = true';
} else {
echo 'baz = false';
}
Then have your js check baz to determine whether you should be running these functions or not. You aren't relying 100% on js in this instance, but imo that's better. Your server is going to always know what page/url you are on, and you won't need to worry about browser incompatibilities with your js trying to determine what page it resides on.