My JavaScript Notes

These notes are brief and, hopefully, will improve as I learn.
If you have comments to improve them, send me a note.

Define document as HTML

<html>

Head Section

Script tags are most often found in the Head section.

Functions, more complex scripts, and defining external scripts (.js) are put in the Head Section.

<head>

<title>My JavaScript Notes</title>

  

      <Script Language=Javascript Type="Text/Javascript">

      <!-- Hide Script from old browsers

                 /*This defines a script comment*/

       // End hiding Script from old beowsers -->

   </Script>

</head>

 

 

Body Section

Scripts that write text to the screen, or write HTML are best put in the Body section.

<body>

   <Script Language=Javascript Type="Text/Javascript">

      document.write("<B>Hello, world!</B.")

   </Script>

 

</body>

End of document. </html>

Misc


 

The text at right is displayed using script in the coding of this page.

 

 

A notice that will display in old browsers.

<noscript>

    <p>This page requires JavaScript</p>

</noscript>

 

Alert user - This coding triggered the message box when this page loaded.

alert("Welcome to MY JavaScript Notes. Click OK to continue.")

 

 

Redirect user

window.location="mypage.html"

Definitions

Objects

bicycle

document

document.image.name

Properties

wheel

 

Methods

 

write()

 

bicycle.wheel

document.write()

Event Handler

onMouseover

onMouseout

onClick

onLoad

Variables

myName

myPix

Values

Bob

 

myName="Bob"

Conditional

if (testing){
      then this
   }
else {
      or this
   }

Function

function Speak() {
   alert("Hello")
}

Calling a function

Usually use an event handler.

 

Back