Simple external.js problem

Please support our JavaScript / DHTML / AJAX advertiser: 50% off 6 Months Dedicated Server Hosting from 1&1!
Thread Solved

Join Date: Feb 2009
Posts: 8
Reputation: BimanD is an unknown quantity at this point 
Solved Threads: 0
BimanD BimanD is offline Offline
Newbie Poster

Simple external.js problem

 
0
  #1
Mar 5th, 2009
I am a new JavaScript user. My teacher told me to display my name using javaScript i solvd it using (document.write) command. and then saving it in(.HTML) format.Now my teacher told me to do the above problm using an external .js file. Plz someone help me to solv this problem. My book provides very few infro about .js or external .js.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 324
Reputation: Thirusha is an unknown quantity at this point 
Solved Threads: 53
Thirusha's Avatar
Thirusha Thirusha is offline Offline
Posting Whiz

Re: Simple external.js problem

 
0
  #2
Mar 5th, 2009
try googling "load an external js file". there are loads of examples on the internet.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 961
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 134
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Simple external.js problem

 
0
  #3
Mar 5th, 2009
Ok you wil need to create a flat file and name it as myname.js then save it in the same directory along with your (x)html document.
Here's the code for myname.js:
  1. function printMyName() {
  2. document.write('Your name!'); }
Now incorporate it with your (x)HTML document:
  1. <html>
  2. <head>
  3. <title>Your title</title>
  4. <script type="text/javascript" src="./myname.js"></script>
  5. </head>
  6. <body>
  7. <p><script type="text/javascript">
  8. // Now let's call the function on the external .js
  9.  
  10. printMyName();</script></p>
  11. </body>
  12. </html>
Last edited by essential; Mar 5th, 2009 at 8:51 am.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,058
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 124
Featured Poster
serkan sendur serkan sendur is offline Offline
Banned

Re: Simple external.js problem

 
0
  #4
Mar 5th, 2009
BimanD, why dont you mark this thread as solved?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 779 | Replies: 3
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC