Saturday, 23 April 2016

Calling a script from an external file

We Can just recall the previous example of image switching to understand how to call script externally.
 Let's have a look.


click on the image

</body> </html>
Using the tag
  <script type="text/javascript" src="functions.js"> </script> 
we can call the script externally. Always write script in file with extension ".js".
function imageswitch(){
var image = document.getElementById('switchimage');
image.src = "flower_two.jpg";
image.src = "flower_one.jpg";
Note: Make sure that the both html and js file locations are the same or else defime them specifically

No comments:

Post a Comment