prb03002 Posted December 28, 2006 Share Posted December 28, 2006 I just started learning JavaScript and was trying to see how the external script works. Unfortunately, I was unsuccessful . I created a JavaScript document and tried to use that as an external script in a HTML file but it doesn't print the document out. Any suggestions? Note: My location for the document is correct Link to comment Share on other sites More sharing options...
jesh Posted December 28, 2006 Share Posted December 28, 2006 Make sure that there aren't any html tags (including <script></script>) in your external javascript file and make sure that you remember to close your script element with a separate </script> tag.This works: <script type="text/javascript" src="myfile.js"></script> This doesn't: <script type="text/javascript" src="myfile.js" /> If this doesn't help, you'll probably have to post your code. Link to comment Share on other sites More sharing options...
prb03002 Posted December 28, 2006 Author Share Posted December 28, 2006 Thats what I had before but it didn't show up. This is the code for the HTML file: <html><head><title>external</title></head><body><script src="jstext.js"></script><p>The actual script is in an external script file called "jstext.js".</p></body></html> and the code to the javascript document is: My name is Prateek. I am learning how to use JavaScript. Link to comment Share on other sites More sharing options...
jesh Posted December 28, 2006 Share Posted December 28, 2006 and the code to the javascript document is: My name is Prateek. I am learning how to use JavaScript. If that is actually what you had in your javascript file, the reason it's not displaying is because that isn't javascript. Javascript would look more like this:document.write("My name is Prateek. I am learning how to use JavaScript."); Link to comment Share on other sites More sharing options...
MrAdam Posted December 28, 2006 Share Posted December 28, 2006 you might also want to get into the habbit of writing: <script type="text/javascript" src="jstext.js"> Link to comment Share on other sites More sharing options...
prb03002 Posted December 29, 2006 Author Share Posted December 29, 2006 That helps...thanks a lot!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now