So before you try to do anything to an object that might not exist on a particular page, put in the following line of code:
if (document.getElementById('the_id_of_the_object') != undefined)
{
//code goes here
}
Again, something super simple but may save you some problems in you're building a larger site with pages that might not have the same objects but share the same scripts.
No comments:
Post a Comment