Where did it come from• Originally called LiveScript at Netscape started out to be a server side scripting language for providing database connectivity and dynamic HTML generation on Netscape Web Servers.• Netscape decided it would be a good thing for their browsers and servers to speak the same language so it got included in Navigator.• Netscape in alliance with Sun jointly announced the language and its new name Java Script• Because of rapid acceptance by the web community Microsoft forced to include in IE Browser
ArraysArrays are usually a group of the same variable type that use an index numberto distinguish them from each other. Arrays are one way of keeping a programmore organized. Creating arrays: Initializing an array: • var badArray = new Array(10); • Var myArray= new Array(“January”,” February”,” // Creates an empty Array thats sized March”); for 10 elements. • var myArray = [January, February, March]; • var goodArray= ; document.write(myArray);//output: January //Creates an Array with 10 as the first document.write(myArray);//output: February element. document.write(myArray);//output: March
2) Confirm Box• A confirm box is often used if we want the user to verify or accept something.• When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.• If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false. <script> var r=confirm("Press a button!"); if (r==true) document.write("You pressed OK!“); else document.write("You pressed Cancel!“); </script>
3) Prompt Box• A prompt box is often used if you want the user to input a value before entering a page.• When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value.• If the user clicks "OK“, the box returns the input value. If the user clicks "Cancel“, the box returns null. <script> x=prompt (“Please enter your name”, “sahil goel ”) document.write(“Welcome <br>”+x) </script>
DOM• The Document Object Model (DOM) is the model that describes how all elements in an HTML page, like input fields, images, paragraphs etc., are related to the topmost structure: the document itself. By calling the element by its proper DOM name, we can influence it.• In DOM each object, whatever it may be exactly, is a Node.Node object: We can traverse through different nodes with the help of certainnode properties and methods:Eg: firstChild, lastChild, parentNode, nextSibling, previousSibling etc.Document object:The Document object gives us access to the documentsdata. Some document methods are:Eg: getElementById(), getElementsByTagName() etc.
Parts of a Cookie Object• name – An identifier by which we reference a particular cookie.• value – The information we wish to save, in reference to a particular cookie.• expires – A GMT-formatted date specifying the date (in milliseconds) when a cookie will expire.• path – Specifies the path of the web server in which the cookie is valid. By default, set to the path of the page that set the cookie. However, commonly specified to /, the root directory.• domain – Specifies the domain for which the cookie is valid. Set, by default, only to the full domain of a page..• secure – Specifies that a web browser needs a secure HTTP connection to access a cookie.
Cookie limitations:• A given domain may only set 20 cookies per machine.• A single browser may only store 300 cookies.• Browsers limit a single cookie to 4KB.