I’ve often had to set up onload events that execute for only a single page. I’ve both hardcoded those function calls right into the markup and I’ve done page detection in a shared js file (parsing the current URL, ew!). Neither solution is rather pretty. The below solution keeps things unobtrusive.
Set up the body tag with an ID that identifies the page, such as:
1 2 3 4 5 6 7 8 9 10 11 12
Your document ready code executes for the same for all pages:
However this will fail if that object (and onload function) are not defined. But you can fix it with a little more code..
1 2 3 4 5 6 7 8 9