igor.learner Posted April 22, 2013 Share Posted April 22, 2013 Hello. I am doing a tutorial on youtube, and a guy (teacher, i am not sure if I can advertise him here) is showing a lesson - "Calling function from another function" on a video, he is writing and generating the code to the web page, but I write the same code - nothing happens. My code is: <html><head><title>Tutorial</title><script type="text/javascript">function doFirst() { document.write("one two three"); }function doSecond() { document.write("My name is Juris"); }function start() { function doFirst(); function doSecond(); } start();</script></head><body></body></html> - it is very basic, but it is not popping on my screen. I do not understand why? I have checked everything for mistakes. Does somebody know the answer? Link to comment Share on other sites More sharing options...
jeffman Posted April 22, 2013 Share Posted April 22, 2013 function start() {function doFirst();function doSecond();} Link to comment Share on other sites More sharing options...
Ingolme Posted April 22, 2013 Share Posted April 22, 2013 The start() function should be called in the <body> section of the document, content in the head isn't meant to be rendered (thought browsers do it anyways since they're designed to save bad coders from themselves). But even then, document.write() will probably cause trouble, it's a good idea to never use it. If you want to display some text on the page, manipulate the innerHTML or create a text node and append it to the body element. function doFirst() { document.body.innerHTML += "one two three";} Link to comment Share on other sites More sharing options...
igor.learner Posted April 22, 2013 Author Share Posted April 22, 2013 Deirdre's Dad thanks !I was literally looking at my code about 5 times and comparing it to the code on the video, but somehow I did not see the mistake you wrote about. It works now. In programming you need such a punctuality and, how is it in english, "proof reading", everything can just not work if you do not put one word in Foxy ModIt is something new for me, it works as well. I will try to remember that. 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