Results 1 to 2 of 2

Thread: Quick Question?

  1. #1
    Join Date
    Dec 2013

    Quick Question?

    Below is an example of code I have been reading through theJavascript into on http://www.w3schools.com/js/js_whereto.asp and I cannot for the life of me figure out why you woud want to use the document.write command instead of just normal means (<p>TEST</p>)

    Can someone enlighten me?

    < html>


    <h1>My First Web Page</h1>

    <p>My First Paragraph.</p>

    <button onclick="myFunction()">Try it</button>

    function myFunction()
    document.write("Oops! The document disappeared!");


  2. #2
    Join Date
    Oct 2012
    document.write() is document's object method for dynamically "writing" text to the web document (that is your web page). <p></p> is a standard HTML tag used to insert (not dynamically) paragraphs into a web document.

    So above web document contains besides HTML "h1" and "p" tags a button whose onclick event handler is connected to the myfFunction() which when called writes down to the web page "Oops! The document disappeared!" text.
    Last edited by tech_soul8; 12-10-2013 at 12:07 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center