View Single Post
  #1 (permalink)  
Old 12-05-2006, 02:34 PM
TcM's Avatar   
TcM TcM is offline
Moderator
 
Join Date: Aug 2006
Location: In a technologic world :p
Posts: 7,360
Rep Power: 67
TcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud of
Default JavaScript:Tutorial, Using an External Script

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!!

Code:
test = new Date()
month = test.getMonth()
month = (month * 1) + 1
day = test.getDate()
year = test.getFullYear()
document.write(" ",month,"/",day,"/",year," ")
And this code in the main HTML file:-

Code:
<SCRIPT SRC="External Script.js">
</SCRIPT>
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!

A Preview:-
None

Conclusion:-
As Always Feedback is welcome and the full source is attached!!
Attached Files To view attachments your post count must be 1 or greater. Your post count is 0 momentarily.
Reply With Quote

Sponsored Links