Hello: Simple JavaScript Code

Topics

HTML, CSS, Javascript
Structure, Presentation, Behavior

Client vs. Server

HTML files link to each other

CSS locations 
      inline
      internal style sheet (head)
      external style sheet (separate file)

Javascript locations 
      head 
      external file

Javascript output
      alert
      document.write
      DOM manipulation ***

<!DOCTYPE html>

<!-- FILE: hello.html -->
<!-- wyatt -->

<html>
<head> 
    <title>hello: simple js code</title>
    <meta charset="UTF-8" />
    <script src="hello.js"></script>            
    <link rel="stylesheet" href="hello.css" />  
</head>
<body>
    

Hello World!

Note that you see the alert box, THEN the document.write.

</body> </html>

/* FILE: hello.css
   wyatt            
*/

   /* element styling */
   body
   {
     background-color:white;
   }
   
   /* class styling */   
   .sample
   {
     background-color:#ddd;
     color:red;  
   }

// FILE: hello.js
// wyatt

// says hello with an alert box
function helloAlert()
{
  alert('Hello World!'); // ONLY executed when called
}


// says hello in the document
function helloWrite()
{
  document.write('Hello World!'); // ONLY executed when called
}