samedi 18 avril 2015

Two methods replacing each other (window.onload/Canvas JS)?

I haven't been working with javascript before, so I am still learning the basics.


I have included two javascript files in my main file called index.html. The reason for this is to let users select which javascript file to show (diagram 1 or diagram 2) by clicking on the navigation tool bar. The problem is that both of these javascript files have a equal method called window.onload, so they replace each other. How can I prevent these two javasript files to replace each other?


First javascript file:



window.onload = function {// Preview diagram 1}


Second javascript file:



window.onload = function {// Preview diagram 2}


Here is a snip of what I have in my index.html



<script type="text/javascript" src="js/diagram1.js"></script>
<script type="text/javascript" src="js/diagram2.js"></script>

Aucun commentaire:

Enregistrer un commentaire