I was wondering what would be the best way to execute a java-script code only on specific pages.
Let\'s imagine we have a template-based web-site, rewrite rule for t
A little different approach than checking the URL path : You can group page specific event handlers in a single function and then in each include, have a domready which will call these functions.
Eg: in script.js
you have two functions (outside domready) viz. onPage1Load()
and onPage2Load()
.
While in your page1.php
you have a $(document).ready(onPage1Load)
and so on for other pages. This will make sure that unintended event handlers are not registered.