Categories:

So what's the problem?

First of all, there is no limit as to the number of scripts a page can contain (other than the "physical" limit), just like there isn't any cap on how much text a page can supposedly hold. Moving on...

The reason why two working scripts may mysteriously not work when put together is simple- script conflict. You see, any duplication in variable declaration, function name, or event-handler access in two scripts can cause at least one, if not both scripts to become inoperative. However, while the possibilities are great, the chances are not. The fact is, 95% of script conflicts I've looked over are the result of one type of conflict- duplication in event-handler access; in particular, the body ONLOAD event handler. Allow me to explain just what that means, and how you can go about getting a cease-fire, so both scripts co-exist merrily together on one page.

Many scripts are set to run after an "event" has occurred, such as the moving of the mouse over a link or the completed loading of the document. The later is the most common, and takes the following two forms:

1) <body ONLOAD="runscript()">
2) window.onload=runscript //appears inside the <script> tag

Just for ease of reference, let's call the first form "delta", and the second, "beta" from hereon. If you see one of the above two lines in your page (where "runscript" varies depending on the script), you know the containing script is set to run after the document has loaded. If you have two or more scripts that EACH contain either delta or beta, you have a conflict on your hand.