Introduction:-
Here in this tutorial I will tell you how to use an External JavaScript file, so if you have a chunk of code that will be used in multiple pages, you will have to make one Script and then call it from the pages instead of making the same code over and over again!
Solution:-
Open a Text Editor and paste the following code and save it as <<Name>>.js I named it 'External Script.js', this is just a script that will show the time but here you can insert whatever you want!!
And this code in the main HTML file:-Code:test = new Date() month = test.getMonth() month = (month * 1) + 1 day = test.getDate() year = test.getFullYear() document.write(" ",month,"/",day,"/",year," ")
Explanation:-Code:<SCRIPT SRC="External Script.js"> </SCRIPT>
Here we are just calling the External Script, instead of "External Script.js" make whatever name you named your script!Code:<SCRIPT SRC="External Script.js"> </SCRIPT>
A Preview:-
None
Conclusion:-
As Always Feedback is welcome and the full source is attached!!


LinkBack URL
About LinkBacks





Reply With Quote





Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum