// Client side Javascript by Sandeep Desai (http://www.thedesai.net) // all global variables are stored in window object // DOM Level 0 W3C standard /* window +- self, window, parent, top properties +- navigator +- frames[] +- location +- history +- screen +- document +- anchors[] +- links[] +- images[] +- applets[] +- embeds[] +- forms[] +-- array of HTML objects (Button, CheckBox, FileUpload (Hidden, Password, Radio, Reset, Select, Submit, Text, TextArea) Select has options[] object */ // use Javascript snippets anywhere in HTML // // // type tag may not work with all browsers // // Specify in that we use only JavaScript language in this HTML // // When writing // tell Browser that code does not add any content // May improve performance while rendering page // // include javascript by // Javascript in URLs, with the URL below Javascript code is executed // and the output of the last statement is dispalyed if not output returned // current document is not modified // Javascript in URL is useful in places where we don't have events // can be use in href of hyperlink or form // javascript: var now = new Date(); "" + now; // javascript:alert("hello world!'); // open in new window void required so that the return value of window.open not used // javascript:window.open("about:blank");void 0; // Javascript code executed as HTML is parsed and displayed // do not refer to HTML elements that have not been defined // HTML cannot be dispalyed until script has finished executing // event handlers can be invoked before the entire document is displayed // as browser may display partial document while the rest of the document is being downloaded // hence define all functions in the the // check for object existence before manipulation e.g if (parent.frames[1] == null) return; or use try catch // alternatively use the onload event which is called when document fully loaded // // Window and vairable lifetime // when new document is loaded windows object is reset to defaults // if multiple windows or frames code can refer to other windows // window object is valid as long as top-level window is open /**************** Common events *********/ // onclick() used by buttons and tags if onClick() returns false do browser does nothing // onmousedown(), onmouseup() onmouseover(), onmouseout() // onchange() support by ,