Java Script by zyr10796

VIEWS: 38 PAGES: 16

									                          Java Script
<html>
   <head>
   <title>This is a first JavaScript example</title>
   <script language="javascript">
   .
   .
   .
   </script>
   </head>

   <body>
   This is a first JavaScript example.
   </body>
</html>
            Hierarchical Objects
                     Window
                      Frame
                     Location
                      History
                    Navigator
                    document
                      image
                       form
                        text
XMLHttpRequest ??
Hierarchy Objects




Object              Properties      Methods        Event Handlers
Window              defaultStatus   alert          onLoad
                    frames          blur           onUnload
                    opener          close          onBlur
                    parent          confirm        onFocus
                    scroll          focus
                    self            open
                    status          prompt
                    top             clearTimeout
                    window          setTimeout
Frame               defaultStatus   alert          none (The onLoad and
                    frames          blur           onUnload event handlers
                    opener          close          belong to the Window
                    parent          confirm        object)
                    scroll          focus
                    self            open
                    status          prompt
                    top             clearTimeout
                    window          setTimeout
Location            hash            reload         none
                    host            replace
                    hostname
                    href
                    pathname
                    por
                    protocol
                    search
History     length         back          none
            forward
            go
Navigator   appCodeName    javaEnabled   none
            appName
            appVersion
            mimeTypes
            plugins
            userAgent
document    alinkColor     clear         none (the onLoad and
            anchors        close         onUnload event handlers
            applets        open          belong to the Window
            area           write         object.
            bgColor        writeln
            cookie
            fgColor
            forms
            images
            lastModified
            linkColor
            links
            location
            referrer
            title
            vlinkColor
image   border         none     none
        complete
        height
        hspace
        lowsrc
        name
        src
        vspace
        width
form    action         submit   onSubmit
        elements       reset    onReset
        encoding
        FileUpload
        method
        name
        target
text    defaultValue   focus    onBlur
        name           blur     onCharge
        type           select   onFocus
        value                   onSelect
Built-in Objects
     Array
      Data
     String
Built-in Objects




Object             Properties   Methods             Event Handlers
Array              length       join                none
                                reverse
                                sort xx
Date               none         getDate             none
                                getDay
                                getHours
                                getMinutes
                                getMonth
                                getSeconds
                                getTime
                                getTimeZoneoffset
                                getYear
                                parse
                                prototype
                                setDate
                                setHours
                                setMinutes
                                setMonth
                                setSeconds
                                setTime
                                setYear
                                toGMTString
                                toLocaleString
                                UTC
String   length      anchor        Window
         prototype   big
                     blink
                     bold
                     charAt
                     fixed
                     fontColor
                     fontSize
                     indexOf
                     italics
                     lastIndexOf
                     link
                     small
                     split
                     strike
                     sub
                     substring
                     sup
                     toLowerCase
                     toUpperCase
XMLHttpRequest Object Properties for
 Mozilla, Firefox, Netscape, Chrome
 Property         Description

 channel          Contains the channel used to perform
                  the request. Read-only.
 readyState       Contains the state of the request. Read-
                  only.
 responseText     Contains the response body as a string.
                  Read-only.
 responseXML      Contains the response body as XML.
                  Read-only.
 status           Contains the HTTP status code returned
                  by a request. Read-only.
 statusText       Contains the HTTP response status text.
                  Read-only.
XMLHttpRequest Object Methods for
 Mozilla, Firefox, Netscape, Chrome
 Method                           Description
 overrideMimeType

 abort abort                      Aborts the HTTP request.


 getAllResponseHeaders            Returns all the HTTP headers.
 getAllResponseHeaders

 getResponseHeader                Returns the value of an HTTP
 getResponseHeader                header.

 openRequest                      Native (nonscript) method to open a
 Open / send / setRequestHeader   request.

 OverrideMimeType                 Overrides the MIME type the server
                                  returns.
      Opening XMLRequest Object
• open("method", "URL"[, asyncFlag[, "userName"[, "password"]]])




• XMLHttpRequestObject.open(“GET”, datasource);
  A in ajax stands for asynchronous
• handshaking

function getData(dataSource, divID)
   {
   if(XMLHttpRequestObject) {
         XMLHttpRequestObject.open("GET", dataSource);
         XMLHttpRequestObject.onreadystatechange = callback()
                         }
   }

function callback()
{
.
.
.
}
            Shortcut for callback()
function getData(dataSource, divID)
   {
   if(XMLHttpRequestObject) {
        XMLHttpRequestObject.open("GET", dataSource);
        XMLHttpRequestObject.onreadystatechange = function()
        {
                .
                .
                .
        }
     }
   }
Ready state property
status

								
To top