I am trying to stop a script from firing on certain pages. IS there a way I could do that by reading strings from urls and prvent the function from loading in those specific pages. Is it really possible? I want to run the script in all the otehr pages and the script is included at a template level
Share
Don’t do it via the page URLs. Instead, do something like adding a class to the
<html>tag for the pages where the script should (or shouldn’t) run, and have it check that before doing anything.So:
and then the script can be predicated on that like this:
(Obviously the code shouldn’t run before the body is loaded, so it should be imported at the end or else the code should be in a “ready” or “load” handler.)