java script full metirial part1

Upload: abhishek

Post on 04-Jun-2018

247 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Java Script Full Metirial Part1

    1/118

    JavaScriptIntroduction Previous Next Chapter

    JavaScript is the most popular scripting language on the internet, and works in all majorbrowsers, such as nternet !xplorer, "ire#ox, Chrome, $pera, and Sa#ari%

    &hat 'ou Should (lread) *now

    +e#ore )ou continue )ou should have a basic understanding o# the #ollowing

    -./0 and CSS

    # )ou want to stud) these subjects #irst, #ind the tutorials on our -ome page%

    &hat is JavaScript1

    JavaScript was designed to add interactivit) to -./0 pages

    JavaScript is a scripting language

    ( scripting language is a lightweight programming language

    JavaScript is usuall) embedded directl) into -./0 pages

    JavaScript is an interpreted language 2means that scripts execute without preliminar) compilation3

    !ver)one can use JavaScript without purchasing a license

    (re Java and JavaScript the same1

    N$4

    Java and JavaScript are two completel) di##erent languages in both concept and design4

    Java 2developed b) Sun /icros)stems3 is a power#ul and much more complex programming language 5 in thesame categor) as C and C66%

    &hat Can JavaScript do1

    JavaScript gives HTML designers a programming tool - -./0 authors are normall) not

    programmers, but JavaScript is a scripting language with a ver) simple s)ntax4 (lmost an)one can putsmall 7snippets7 o# code into their -./0 pages

    JavaScript can react to events - ( JavaScript can be set to execute when something happens, like

    when a page has #inished loading or when a user clicks on an -./0 element JavaScript can read and write HTML elements - ( JavaScript can read and change the content o# an

    -./0 element

    JavaScript can be used to validate data - ( JavaScript can be used to validate #orm data be#ore it is

    submitted to a server% .his saves the server #rom extra processing

    JavaScript can be used to detect the visitor's browser5 ( JavaScript can be used to detect the

    visitor8s browser, and 5 depending on the browser 5 load another page speci#icall) designed #or thatbrowser

    JavaScript can be used to create cookies5 ( JavaScript can be used to store and retrieve in#ormation

    on the visitor8s computer

    http://www.w3schools.com/js/default.asphttp://www.w3schools.com/js/js_howto.asphttp://www.w3schools.com/default.asphttp://www.w3schools.com/js/default.asphttp://www.w3schools.com/js/js_howto.asphttp://www.w3schools.com/default.asp
  • 8/13/2019 Java Script Full Metirial Part1

    2/118

    JavaScript 9 !C/(Script

    JavaScript is an implementation o# the !C/(Script language standard% !C/(5:;: is the o##icial JavaScriptstandard%

    JavaScript was invented b) +rendan !ich at Netscape 2with Navigator :%>;%

    .he o##icial standardi?ation was adopted b) the !C/( organi?ation2an industr) standardi?ation association3 in=>>@%

    .he !C/( standard 2called !C/(Script5:;:3 was approved as an international S$ 2S$A!C =;:;:3 standard in=>>B%

    .he development is still in progress%

    Previous Next Chapter

    JavaScriptHow To Previous Next Chapter

    .he -./0 scriptD tag is used to insert a JavaScript into an -./0 page%

    &riting to .he -./0 Eocument

    .he example below writes a pD element with current date in#ormation to the -./0 document

    !xample

    My First Web Page

    documet!rite#"

    " $ %ate#& $ "

    "&'

    Try it yoursel !

    http://www.ecma-international.org/http://www.w3schools.com/js/default.asphttp://www.w3schools.com/js/js_howto.asphttp://www.w3schools.com/js/js_intro.asphttp://www.w3schools.com/js/js_whereto.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_writehttp://www.ecma-international.org/http://www.w3schools.com/js/default.asphttp://www.w3schools.com/js/js_howto.asphttp://www.w3schools.com/js/js_intro.asphttp://www.w3schools.com/js/js_whereto.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_write
  • 8/13/2019 Java Script Full Metirial Part1

    3/118

  • 8/13/2019 Java Script Full Metirial Part1

    4/118

    .he lines between the scriptD and AscriptD contain the JavaScript and are executed b) the browser%

    n this case the browser will replace the content o# the -./0 element with id97demo7, with the current date

    My First Web Page

    ,his is a paragraph!

    documet!get(lemet)y*d#"demo"&!ier+,M-=%ate#&'

    &ithout the scriptD tag2s3, the browser will treat 7document%get!lement+)d27demo73%inner-./09Eate23F7 aspure text and just write it to the page.r) it )oursel#

    Some +rowsers do Not Support JavaScript

    +rowsers that do not support JavaScript, will displa) JavaScript as page content%

    .o prevent them #rom doing this, and as a part o# the JavaScript standard, the -./0 comment tag should beused to 7hide7 the JavaScript%

    Just add an -./0 comment tag 455 be#ore the #irst JavaScript statement, and a 55D 2end o# comment3 a#ter thelast JavaScript statement, like this

  • 8/13/2019 Java Script Full Metirial Part1

    5/118

  • 8/13/2019 Java Script Full Metirial Part1

    6/118

    !xample

    2uctio display%ate#&3documet!get(lemet)y*d#"demo"&!ier+,M-=%ate#&'4

    My First Web Page

    %isplay %ate

    Try it yoursel !

    Scripts in headD and bod)D

    'ou can place an unlimited number o# scripts in )our document, and )ou can have scripts in both the bod) and

    the head section at the same time%

    t is a common practice to put all #unctions in the head section, or at the bottom o# the page% .his wa) the) areall in one place and do not inter#ere with page content%

    Gsing an !xternal JavaScript

    JavaScript can also be placed in external #iles%

    !xternal JavaScript #iles o#ten contain code to be used on several di##erent web pages%

    !xternal JavaScript #iles have the #ile extension %js%

    "ote#!xternal script cannot contain the scriptDAscriptD tags4

    .o use an external script, point to the %js #ile in the 7src7 attribute o# the scriptD tag

    !xample

    http://www.w3schools.com/js/tryit.asp?filename=tryjs_eventshttp://www.w3schools.com/js/tryit.asp?filename=tryjs_events
  • 8/13/2019 Java Script Full Metirial Part1

    7/118

    Try it yoursel !

    "ote#Hemember to place the script exactl) where )ou normall) would write the script4

    Previous Next Chapter

    JavaScriptStatements Previous Next Chapter

    JavaScript is a seIuence o# statements to be executed b) the browser%

    JavaScript is Case Sensitive

    Gnlike -./0, JavaScript is case sensitive 5 there#ore watch )our capitali?ation closel) when )ou write JavaScriptstatements, create or call variables, objects and #unctions%

    JavaScript Statements

    ( JavaScript statement is a command to a browser% .he purpose o# the command is to tell the browser what todo%

    .his JavaScript statement tells the browser to write 7-ello Eoll)7 to the web page

    documet!rite#"+ello %olly"&'

    t is normal to add a semicolon at the end o# each executable statement% /ost people think this is a goodprogramming practice, and most o#ten )ou will see this in JavaScript examples on the web%

    .he semicolon is optional 2according to the JavaScript standard3, and the browser is supposed to interpret theend o# the line as the end o# the statement% +ecause o# this )ou will o#ten see examples without the semicolon atthe end%

    http://www.w3schools.com/js/tryit.asp?filename=tryjs_externalexamplehttp://www.w3schools.com/js/js_howto.asphttp://www.w3schools.com/js/js_statements.asphttp://www.w3schools.com/js/js_whereto.asphttp://www.w3schools.com/js/js_comments.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_externalexamplehttp://www.w3schools.com/js/js_howto.asphttp://www.w3schools.com/js/js_statements.asphttp://www.w3schools.com/js/js_whereto.asphttp://www.w3schools.com/js/js_comments.asp
  • 8/13/2019 Java Script Full Metirial Part1

    8/118

    "ote#Gsing semicolons makes it possible to write multiple statements on one line%

    JavaScript Code

    JavaScript code 2or just JavaScript3 is a seIuence o# JavaScript statements%

    !ach statement is executed b) the browser in the seIuence the) are written%

    .his example will write a heading and two paragraphs to a web page

    !xample

    documet!rite#",his is a headig"&'documet!rite#"

    ,his is a paragraph!

    "&'documet!rite#"

    ,his is aother paragraph!

    "&'

    Try it yoursel !

    JavaScript +locks

    JavaScript statements can be grouped together in blocks%

    +locks start with a le#t curl) bracket , and end with a right curl) bracket K%

    .he purpose o# a block is to make the seIuence o# statements execute together%

    .his example will write a heading and two paragraphs to a web page

    !xample

    3documet!rite#",his is a headig"&'documet!rite#"

    ,his is a paragraph!

    "&'documet!rite#"

    ,his is aother paragraph!

    "&'4

    Try it yoursel !

    .he example above is not ver) use#ul% t just demonstrates the use o# a block% Normall) a block is used to groupstatements together in a #unction or in a condition 2where a group o# statements should be executed i# acondition is met3%

    'ou will learn more about #unctions and conditions in later chapters%

    http://www.w3schools.com/js/tryit.asp?filename=tryjs_statementshttp://www.w3schools.com/js/tryit.asp?filename=tryjs_blockshttp://www.w3schools.com/js/tryit.asp?filename=tryjs_statementshttp://www.w3schools.com/js/tryit.asp?filename=tryjs_blocks
  • 8/13/2019 Java Script Full Metirial Part1

    9/118

    Previous Next Chapter

    JavaScript)omments Previous Next Chapter

    JavaScript comments can be used to make the code more readable%

    JavaScript Comments

    Comments can be added to explain the JavaScript, or to make the code more readable%

    Single line comments start with AA%

    .he #ollowing example uses single line comments to explain the code

    !xample

    // Write a headigdocumet!rite#",his is a headig"&'// Write to paragraphs6documet!rite#"

    ,his is a paragraph!

    "&'

    documet!rite#"

    ,his is aother paragraph!

    "&'

    Try it yoursel !

    JavaScript /ulti50ine Comments

    /ulti line comments start with AL and end with LA%

    .he #ollowing example uses a multi line comment to explain the code

    !xample

    /7,he code belo ill riteoe headig ad to paragraphs7/documet!rite#",his is a headig"&'

    http://www.w3schools.com/js/js_whereto.asphttp://www.w3schools.com/js/js_comments.asphttp://www.w3schools.com/js/js_statements.asphttp://www.w3schools.com/js/js_variables.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_comments1http://www.w3schools.com/js/js_whereto.asphttp://www.w3schools.com/js/js_comments.asphttp://www.w3schools.com/js/js_statements.asphttp://www.w3schools.com/js/js_variables.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_comments1
  • 8/13/2019 Java Script Full Metirial Part1

    10/118

    documet!rite#"

    ,his is a paragraph!

    "&'documet!rite#"

    ,his is aother paragraph!

    "&'

    Try it yoursel !

    Gsing Comments to Prevent !xecution

    n the #ollowing example the comment is used to prevent the execution o# a single code line 2can be suitable #ordebugging3

    !xample

    //documet!rite#",his is a headig"&'documet!rite#"

    ,his is a paragraph!

    "&'

    documet!rite#"

    ,his is aother paragraph!

    "&'

    Try it yoursel !

    n the #ollowing example the comment is used to prevent the execution o# a code block 2can be suitable #ordebugging3

    !xample

    /7

    documet!rite#",his is a headig"&'documet!rite#"

    ,his is a paragraph!

    "&'documet!rite#"

    ,his is aother paragraph!

    "&'7/

    Try it yoursel !

    Gsing Comments at the !nd o# a 0ine

    n the #ollowing example the comment is placed at the end o# a code line

    !xample

    documet!rite#"+ello"&' // Write "+ello"documet!rite#" %olly0"&' // Write " %olly0"

    http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments2http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments3http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments4http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments2http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments3http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments4
  • 8/13/2019 Java Script Full Metirial Part1

    11/118

    Try it yoursel !

    Previous Next Chapter

    JavaScript*ariables Previous Next Chapter

    Mariables are 7containers7 #or storing in#ormation%

    Eo 'ou Hemember (lgebra "rom School1

    Eo )ou remember algebra #rom school1 x9, )9;, ?9x6)

    Eo )ou remember that a letter 2like x3 could be used to hold a value 2like 3, and that )ou could use thein#ormation above to calculate the value o# ? to be ==1

    .hese letters are called variables, and variables can be used to hold values 2x93 or expressions 2?9x6)3%

    JavaScript Mariables

    (s with algebra, JavaScript variables are used to hold values or expressions%

    ( variable can have a short name, like x, or a more descriptive name, like carname%

    Hules #or JavaScript variable names

    Mariable names are case sensitive 2) and ' are two di##erent variables3

    Mariable names must begin with a letter or the underscore character

    "ote#+ecause JavaScript is case5sensitive, variable names are case5sensitive%

    !xample

    ( variable8s value can change during the execution o# a script% 'ou can re#er to a variable b) its name to displa)or change its value%

    .his example will show )ou how

    Eeclaring 2Creating3 JavaScript Mariables

    Creating variables in JavaScript is most o#ten re#erred to as 7declaring7 variables%

    http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments5http://www.w3schools.com/js/js_statements.asphttp://www.w3schools.com/js/js_variables.asphttp://www.w3schools.com/js/js_comments.asphttp://www.w3schools.com/js/js_operators.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_variablehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_comments5http://www.w3schools.com/js/js_statements.asphttp://www.w3schools.com/js/js_variables.asphttp://www.w3schools.com/js/js_comments.asphttp://www.w3schools.com/js/js_operators.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_variable
  • 8/13/2019 Java Script Full Metirial Part1

    12/118

    'ou declare JavaScript variables with the varke)word

    var x'var carame'

    (#ter the declaration shown above, the variables are empt) 2the) have no values )et3%

    -owever, )ou can also assign values to the variables when )ou declare them

    var x=8'var carame="9olvo"'

    (#ter the execution o# the statements above, the variable +will hold the value ,, and carnamewill hold thevalue *olvo%

    "ote#&hen )ou assign a text value to a variable, use Iuotes around the value%

    "ote## )ou redeclare a JavaScript variable, it will not lose its value%

    0ocal JavaScript Mariables

    ( variable declared within a JavaScript #unction becomes L).Land can onl) be accessed within that #unction%2the variable has local scope3%

    'ou can have local variables with the same name in di##erent #unctions, because local variables are onl)recogni?ed b) the #unction in which the) are declared%

    0ocal variables are destro)ed when )ou exit the #unction%

    'ou will learn more about #unctions in a later chapter o# this tutorial%

    Olobal JavaScript Mariables

    Mariables declared outside a #unction become /L%.L, and all scripts and #unctions on the web page can accessit%

    Olobal variables are destro)ed when )ou close the page%

    # )ou declare a variable, without using 7var7, the variable alwa)s becomes /L%.L%

    (ssigning Malues to Gndeclared JavaScript Mariables

    # )ou assign values to variables that have not )et been declared, the variables will automaticall) be declared asglobal variables%

    .hese statements

  • 8/13/2019 Java Script Full Metirial Part1

    13/118

    x=8'carame="9olvo"'

    will declare the variables x and carname as global variables 2i# the) don8t alread) exist3%

    JavaScript (rithmetic

    (s with algebra, )ou can do arithmetic operations with JavaScript variables

    y=x8':=y$8'

    'ou will learn more about the operators that can be used in the next chapter o# this tutorial%

    Previous Next Chapter

    JavaScriptperators Previous Next Chapter

    9 is used to assign values%

    6 is used to add values%

    .he assignment operator 0is used to assign values to JavaScript variables%

    .he arithmetic operator 6 is used to add values together%

    y=8':=;'x=y$:'

    .he value o# x, a#ter the execution o# the statements above, is @%

    JavaScript (rithmetic $perators

    (rithmetic operators are used to per#orm arithmetic between variables andAor values%

    Oiven that y0,, the table below explains the arithmetic operators

    perator 1escription $+ample 2esult

    6 (ddition x9)6: x9@ )9

    http://www.w3schools.com/js/js_comments.asphttp://www.w3schools.com/js/js_operators.asphttp://www.w3schools.com/js/js_variables.asphttp://www.w3schools.com/js/js_comparisons.asphttp://www.w3schools.com/js/js_comments.asphttp://www.w3schools.com/js/js_operators.asphttp://www.w3schools.com/js/js_variables.asphttp://www.w3schools.com/js/js_comparisons.asp
  • 8/13/2019 Java Script Full Metirial Part1

    14/118

    5 Subtraction x9)5: x9 )9

    L /ultiplication x9)L: x9=< )9

    A Eivision x9)A: x9:% )9

    Q /odulus 2division remainder3 x9)Q: x9= )9

    66 ncrement x966) x9; )9;

    x9)66 x9 )9;

    55 Eecrement x955) x9R )9R

    x9)55 x9 )9R

    JavaScript (ssignment $perators

    (ssignment operators are used to assign values to JavaScript variables%

    Oiven that +034and y0,, the table below explains the assignment operators

    perator $+ample Same .s 2esult

    9 x9) x9

    69 x69) x9x6) x9=

    59 x59) x9x5) x9

    L9 xL9) x9xL) x9our wn b

  • 8/13/2019 Java Script Full Metirial Part1

    62/118

    Properties

    .he s)ntax #or accessing a propert) o# an object is

    objGame!propGame

    'ou can add properties to an object b) simpl) giving it a value% (ssume that the person$bj alread) exists 5 )oucan give it properties named #irstname, lastname, age, and e)ecolor as #ollows

    persoCbj!2irstame=".oh"'persoCbj!lastame="%oe"'persoCbj!age=A'persoCbj!eyecolor="blue"'

    documet!rite#persoCbj!2irstame&'

    .he code above will generate the #ollowing output

    .oh

    /ethods

    (n object can also contain methods%

    'ou can call a method with the #ollowing s)ntax

    objGame!methodGame#&

    "ote#Parameters reIuired #or the method can be passed between the parentheses%

    .o call a method called sleep23 #or the person$bj

    persoCbj!sleep#&'

    Creating 'our $wn $bjects

    .here are di##erent wa)s to create a new object

    39 )reate a direct instance o an ob

  • 8/13/2019 Java Script Full Metirial Part1

    63/118

    alternative s)ntax 2using object literals3

    persoCbj=32irstame6".oh"Blastame6"%oe"Bage68ABeyecolor6"blue"4'

    (dding a method to the person$bj is also simple% .he #ollowing code adds a method called eat23 to theperson$bj

    persoCbj!eat=eat'

    ?9 )reate an ob

  • 8/13/2019 Java Script Full Metirial Part1

    64/118

    .he newlastname23 #unction de#ines the person8s new last name and assigns that to the person% JavaScript knowswhich person )ou8re talking about b) using 7this%7% So, now )ou can write m)/other%newlastname27Eoe73%

    Previous Next Chapter

    'ou -ave 0earned JavaScript,"ow (hat@ Previous Next Chapter

    JavaScript Summar)

    .his tutorial has taught )ou how to add JavaScript to )our -./0 pages, to make )our web site more d)namic andinteractive%

    'ou have learned how to create responses to events, validate #orms and how to make di##erent scripts run inresponse to di##erent scenarios%

    'ou have also learned how to create and use objects, and how to use JavaScript8s built5in objects%

    "or more in#ormation on JavaScript, please look at our JavaScript examplesand our JavaScript re#erence%

    Now 'ou *now JavaScript, &hat8s Next1

    .he next step is to learn about the -./0 E$/, jWuer), and (J(X%

    # )ou want to learn about server5side scripting, the next step is to learn (SP or P-P%

    HTML 1M

    .he -./0 E$/ de#ines a standard wa) #or accessing and manipulating -./0 documents%

    .he -./0 E$/ is plat#orm and language independent and can be used b) an) programming language like Java,JavaScript, and M+Script%

    # )ou want to learn more about the E$/, please visit our -./0 E$/ tutorial%

  • 8/13/2019 Java Script Full Metirial Part1

    65/118

    (J(X 9 (s)nchronous JavaScript and X/0%

    (J(X is not a new programming language, but a new wa) to use existing standards%

    (J(X is about exchanging data with a server, and update parts o# a web page 5 without reloading the wholepage%

    !xamples o# applications using (J(X Ooogle /aps, Omail, 'outube, and "acebook tabs%

    # )ou want to learn more about (J(X, please visit our (J(X tutorial%

    .S: = :H:

    &hile scripts in an -./0 #ile are executed on the client 2in the browser3, scripts in an (SPAP-P #ile are executedon the server%

    &ith (SPAP-P )ou can d)namicall) edit, change or add an) content o# a &eb page, respond to data submitted

    #rom -./0 #orms, access an) data or databases and return the results to a browser, customi?e a &eb page tomake it more use#ul #or individual users%

    Since (SPAP-P #iles are returned as plain -./0, the) can be viewed in an) browser%

    # )ou want to learn more about (SP, please visit our (SP tutorial%

    # )ou want to learn more about P-P, please visit our P-P tutorial%

    &Schools8 $nline Certi#ication

    .he per#ect solution #or pro#essionals who need to balance work, #amil), andcareer building%

    /ore than ;

  • 8/13/2019 Java Script Full Metirial Part1

    66/118

    Previous Next Chapter

    JavaScript$+amples Previous Next Chapter

    +asic JavaScript !xamples

    &rite to the Eocument with JavaScriptChange -./0 elements with JavaScript(n external JavaScript

    $+amples e+plained

    JavaScript Statements, Comments and +locks

    JavaScript statements%JavaScript blocks%

    Single line comments%/ultiple lines comments%Single line comment to prevent execution%/ultiple lines comment to prevent execution%

    $+amples e+plained

    JavaScript Mariables

    Eeclare a variable, assign a value to it, and displa) it

    $+amples e+plained

    JavaScript Conditional # %%% !lse

    # statement

    #%%%else statementHandom linkSwitch statement

    $+amples e+plained

    JavaScript Popup +oxes

    http://www.w3schools.com/js/js_objects.asphttp://www.w3schools.com/js/js_examples.asphttp://www.w3schools.com/js/js_summary.asphttp://www.w3schools.com/js/js_examples_2.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_writehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_domhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_externalexamplehttp://www.w3schools.com/js/js_howto.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_statementshttp://www.w3schools.com/js/tryit.asp?filename=tryjs_blockshttp://www.w3schools.com/js/tryit.asp?filename=tryjs_comments1http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments2http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments3http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments4http://www.w3schools.com/js/js_statements.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_variablehttp://www.w3schools.com/js/js_variables.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_ifthenhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_ifthenelsehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_randomlinkhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_switchhttp://www.w3schools.com/js/js_if_else.asphttp://www.w3schools.com/js/js_objects.asphttp://www.w3schools.com/js/js_examples.asphttp://www.w3schools.com/js/js_summary.asphttp://www.w3schools.com/js/js_examples_2.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_writehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_domhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_externalexamplehttp://www.w3schools.com/js/js_howto.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_statementshttp://www.w3schools.com/js/tryit.asp?filename=tryjs_blockshttp://www.w3schools.com/js/tryit.asp?filename=tryjs_comments1http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments2http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments3http://www.w3schools.com/js/tryit.asp?filename=tryjs_comments4http://www.w3schools.com/js/js_statements.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_variablehttp://www.w3schools.com/js/js_variables.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_ifthenhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_ifthenelsehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_randomlinkhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_switchhttp://www.w3schools.com/js/js_if_else.asp
  • 8/13/2019 Java Script Full Metirial Part1

    67/118

    (lert box(lert box with line breaksCon#irm boxPrompt box

    $+amples e+plained

    JavaScript "unctions

    Call a #unction"unction with an argument"unction with an argument :"unction that returns a value"unction with arguments, that returns a value

    $+amples e+plained

    JavaScript 0oops

    "or loop

    0ooping through -./0 headers&hile loopEo &hile loop+reak a loop+reak and continue a loopGse a #or%%%in statement to loop through the elements o# an object

    $+amples e+plained

    JavaScript !vents

    (cting to the onclick event(cting to the onmouseover event

    $+amples e+plained

    JavaScript !rror -andling

    .he tr)%%%catch statement

    .he tr)%%%catch statement with a con#irm box

    .he onerror event

    $+amples e+plained

    (dvanced JavaScript !xamples

    Create a welcome cookieSimple timing

    http://www.w3schools.com/js/tryit.asp?filename=tryjs_alerthttp://www.w3schools.com/js/tryit.asp?filename=tryjs_alert2http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirmhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_prompthttp://www.w3schools.com/js/js_popup.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_function1http://www.w3schools.com/js/tryit.asp?filename=tryjs_function2http://www.w3schools.com/js/tryit.asp?filename=tryjs_functionarg2http://www.w3schools.com/js/tryit.asp?filename=tryjs_function_return2http://www.w3schools.com/js/tryit.asp?filename=tryjs_function_returnhttp://www.w3schools.com/js/js_functions.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_fornexthttp://www.w3schools.com/js/tryit.asp?filename=tryjs_fornext_headerhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_whilehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_dowhilehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_breakhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_continuehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_object_for_inhttp://www.w3schools.com/js/js_loop_for.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_eventshttp://www.w3schools.com/js/tryit.asp?filename=tryjs_imagemaphttp://www.w3schools.com/js/js_events.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_try_catchhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_try_catch2http://www.w3schools.com/js/tryit.asp?filename=tryjs_onerrorhttp://www.w3schools.com/js/js_try_catch.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_cookie_usernamehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_timing1http://www.w3schools.com/js/tryit.asp?filename=tryjs_alerthttp://www.w3schools.com/js/tryit.asp?filename=tryjs_alert2http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirmhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_prompthttp://www.w3schools.com/js/js_popup.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_function1http://www.w3schools.com/js/tryit.asp?filename=tryjs_function2http://www.w3schools.com/js/tryit.asp?filename=tryjs_functionarg2http://www.w3schools.com/js/tryit.asp?filename=tryjs_function_return2http://www.w3schools.com/js/tryit.asp?filename=tryjs_function_returnhttp://www.w3schools.com/js/js_functions.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_fornexthttp://www.w3schools.com/js/tryit.asp?filename=tryjs_fornext_headerhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_whilehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_dowhilehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_breakhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_continuehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_object_for_inhttp://www.w3schools.com/js/js_loop_for.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_eventshttp://www.w3schools.com/js/tryit.asp?filename=tryjs_imagemaphttp://www.w3schools.com/js/js_events.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_try_catchhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_try_catch2http://www.w3schools.com/js/tryit.asp?filename=tryjs_onerrorhttp://www.w3schools.com/js/js_try_catch.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_cookie_usernamehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_timing1
  • 8/13/2019 Java Script Full Metirial Part1

    68/118

    (nother simple timing.iming event in an in#inite loop.iming event in an in#inite loop 5 with a Stop button( clock created with a timing eventCreate a direct instance o# an objectCreate an object constructor

    Previous Next Chapter

    +asic JavaScript !xamples

    1)

    My First Web Page

    docme!t#rite$"

    " % &ate$) % "

    ")'

    ()

    My First Web Page

    his is a paragraph

    docme!tget*leme!t+y,d$"demo")i!!er-M.=&ate$)'

    )

    http://www.w3schools.com/js/tryit.asp?filename=tryjs_timing2http://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_infinitehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_stophttp://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_clockhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_create_object1http://www.w3schools.com/js/tryit.asp?filename=tryjs_create_object2http://www.w3schools.com/js/js_summary.asphttp://www.w3schools.com/js/js_examples_2.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_timing2http://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_infinitehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_stophttp://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_clockhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_create_object1http://www.w3schools.com/js/tryit.asp?filename=tryjs_create_object2http://www.w3schools.com/js/js_summary.asphttp://www.w3schools.com/js/js_examples_2.asp
  • 8/13/2019 Java Script Full Metirial Part1

    69/118

    he actal script is i! a! exter!al script 0ile called "xxxjs"

    JavaScript Statements, Comments and +locks

    1)

    docme!t#rite$"his is a headi!g")'docme!t#rite$"

    his is a paragraph

    ")'

    docme!t#rite$"

    his is a!other paragraph

    ")'

    ()

    docme!t#rite$"his is a headi!g")'docme!t#rite$"

    his is a paragraph

    ")'docme!t#rite$"

    his is a!other paragraph

    ")'2
  • 8/13/2019 Java Script Full Metirial Part1

    70/118

    3) JavaScript Mariables

    var 0irst!ame'0irst!ame="-ege"'

    docme!t#rite$0irst!ame)'docme!t#rite$"
    ")'0irst!ame="ove"'docme!t#rite$0irst!ame)'

    he script above declares a variable3assig!s a vale to it3 displays the vale3 cha!ges the vale3a!d displays the vale agai!

    JavaScript Conditional # %%% !lse

    1)

    var d = !e# &ate$)'var time = dget-ors$)'

    i0 $time < 14)

    docme!t#rite$"5ood mor!i!g")'

  • 8/13/2019 Java Script Full Metirial Part1

    71/118

  • 8/13/2019 Java Script Full Metirial Part1

    72/118

  • 8/13/2019 Java Script Full Metirial Part1

    73/118

    JavaScript Popup +oxes

    1 Clert +ox0!ctio! sho#Dalert$)alert$"-ello; , am a! alert box;")'2

    Clert box #ith li!e breas

    0!ctio! dispDalert$)alert$"-ello agai!; his is ho# #e" % 9E!9 % "add li!e breas to a! alert box;")'2

  • 8/13/2019 Java Script Full Metirial Part1

    74/118

  • 8/13/2019 Java Script Full Metirial Part1

    75/118

    JavaScript "unctions

    all a F!ctio!

    0!ctio! displaymessage$)alert$"-ello World;")'2

    +y pressi!g the btto! above3 a 0!ctio! #ill be called he 0!ctio! #ill alert a message

    F!ctio! #ith a! argme!t

  • 8/13/2019 Java Script Full Metirial Part1

    76/118

    0!ctio! my0!ctio!$txt)alert$txt)'2

    +y pressi!g the btto! above3 a 0!ctio! #ill be called #ith "-ello" as a parameter he 0!ctio! #illalert the parameter

    F!ctio! #ith a! argme!t (

    0!ctio! my0!ctio!$txt)alert$txt)'2

  • 8/13/2019 Java Script Full Metirial Part1

    77/118

    Whe! yo clic o! o!e o0 the btto!s3 a 0!ctio! #ill be called he 0!ctio! #ill alertthe argme!t that is passed to it

    F!ctio! that retr! a vale

    0!ctio! myF!ctio!$)

    retr! $"-ello #orld;")'2

    docme!t#rite$myF!ctio!$))

    F!ctio! #ith argme!ts a!d retr! a vale

    0!ctio! prodct$a3b)retr! aKb'2

  • 8/13/2019 Java Script Full Metirial Part1

    78/118

    docme!t#rite$prodct$73))'

    he script i! the body sectio! calls a 0!ctio! #ith t#o parameters $7 a!d )

    he 0!ctio! #ill retr! the prodct o0 these t#o parameters

    JavaScript 0oops

    For loop

    var i=4'0or $i=4'i

  • 8/13/2019 Java Script Full Metirial Part1

    79/118

    0or $i = 1' i

  • 8/13/2019 Java Script Full Metirial Part1

    80/118

    i = 4'dodocme!t#rite$"he !mber is " % i)'

    docme!t#rite$"
    ")'i%%'2#hile $i

  • 8/13/2019 Java Script Full Metirial Part1

    81/118

  • 8/13/2019 Java Script Full Metirial Part1

    82/118

    (cting to the $nClick event

    0!ctio! display&ate$)

    docme!tget*leme!t+y,d$"demo")i!!er-M.=&ate$)'

    2

    My First Web Page

    his is a paragraph

    &isplay &ate

    Mose6ver *ve!t

    0!ctio! #riteext$txt)

    docme!tget*leme!t+y,d$"desc")i!!er-M.=txt'2

  • 8/13/2019 Java Script Full Metirial Part1

    83/118

    Mose over the s! a!d the pla!ets a!d see the di00ere!t descriptio!s

    JavaScript !rror -andling

    ry atch

    var txt=""'

    0!ctio! message$)try adddlert$"Welcome gest;")' 2catch$err)

  • 8/13/2019 Java Script Full Metirial Part1

    84/118

    txt="here #as a! error o! this pageE!E!"' txt%="*rror descriptio!: " % errdescriptio! % "E!E!"' txt%="lic 6H to co!ti!eE!E!"' alert$txt)' 2

    2

    ry atch #ith o!0irm +ox

    var txt=""'0!ctio! message$)try

    adddlert$"Welcome gest;")' 2catch$err) txt="here #as a! error o! this pageE!E!"' txt%="lic 6H to co!ti!e vie#i!g this page3E!"' txt%="or a!cel to retr! to the home pageE!E!"' i0$;co!0irm$txt)) docme!tlocatio!hre0="http://####schoolscom/"' 2

    22

  • 8/13/2019 Java Script Full Metirial Part1

    85/118

    6!*rror *ve!t

    o!error=ha!dle*rr'var txt=""'

    0!ctio! ha!dle*rr$msg3rl3l)txt="here #as a! error o! this pageE!E!"'txt%="*rror: " % msg % "E!"'txt%="R.: " % rl % "E!"'txt%=".i!e: " % l % "E!E!"'txt%="lic 6H to co!ti!eE!E!"'alert$txt)'

    retr! tre'2

    0!ctio! message$)adddlert$"Welcome gest;")'2

    (dvanced JavaScript !xamples

    Create welcome Cookie

    0!ctio! getooie$cD!ame)

  • 8/13/2019 Java Script Full Metirial Part1

    86/118

    var i3x3y3Ccooies=docme!tcooiesplit$"'")'

    0or $i=4'i

  • 8/13/2019 Java Script Full Metirial Part1

    87/118

    ser!ame=prompt$"Please e!ter yor !ame:"3"")'

    i0 $ser!ame;=!ll II ser!ame;="")

    setooie$"ser!ame"3ser!ame3?8)'

    2

    2

    2

    Simple Timig

    0!ctio! timeMsg$)

    var t=setimeot$"alertMsg$)"3444)'

    2

    0!ctio! alertMsg$)

    alert$"-ello")'

    2

  • 8/13/2019 Java Script Full Metirial Part1

    88/118

    Timing event in an Infinite Loop

    var c=4'

    var t'

    var timerDisDo!=4'

    0!ctio! timedo!t$)

    docme!tget*leme!t+y,d$9txt9)vale=c'

    c=c%1'

    t=setimeot$"timedo!t$)"31444)'

    2

    0!ctio! doimer$)

    i0 $;timerDisDo!)

    timerDisDo!=1'

    timedo!t$)'

    2

    2

  • 8/13/2019 Java Script Full Metirial Part1

    89/118

    lic o! the btto! above he i!pt 0ield #ill co!t 0orever3 starti!g at 4

    Timing event in an Infinite Loop with Stop Button

    var c=4'

    var t'

    var timerDisDo!=4'

    0!ctio! timedo!t$)

    docme!tget*leme!t+y,d$9txt9)vale=c'

    c=c%1'

    t=setimeot$"timedo!t$)"31444)'

    2

    0!ctio! doimer$)

    i0 $;timerDisDo!)

  • 8/13/2019 Java Script Full Metirial Part1

    90/118

    timerDisDo!=1'

    timedo!t$)'

    2

    2

    0!ctio! stopo!t$)

    clearimeot$t)'

    timerDisDo!=4'

    2

    lic o! the "@tart co!t;" btto! above to start the timer he i!pt 0ield #ill co!t 0orever3 starti!g at 4lic o! the "@top co!t;" btto! to stop the co!ti!g lic o! the "@tart co!t;" btto! to start thetimer agai!

  • 8/13/2019 Java Script Full Metirial Part1

    91/118

    A clock created with Timing Event

    0!ctio! startime$)

    var today=!e# &ate$)'

    var h=todayget-ors$)'

    var m=todaygetMi!tes$)'

    var s=todayget@eco!ds$)'

    // add a Vero i! 0ro!t o0 !mbers

  • 8/13/2019 Java Script Full Metirial Part1

    92/118

    Create a Direct Intance of !"#ect

    perso!6bj=0irst!ame:"Aoh!"3last!ame:"&oe"3age:843eyecolor:"ble"2

    docme!t#rite$perso!6bj0irst!ame % " is " % perso!6bjage % " years old")'

    reate a! 6bject co!strctor

    0!ctio! perso!$0irst!ame3last!ame3age3eyecolor)this0irst!ame=0irst!ame'thislast!ame=last!ame'thisage=age'thiseyecolor=eyecolor'2

    myFather=!e# perso!$"Aoh!"3"&oe"3843"ble")'

  • 8/13/2019 Java Script Full Metirial Part1

    93/118

    docme!t#rite$myFather0irst!ame % " is " % myFatherage % " years old")'

    String $bject

    $eturn Length of the String

    var txt = "-ello World;"'docme!t#rite$txtle!gth)'

    St%le String

    var txt = "-ello World;"'

    docme!t#rite$"

    +ig: " % txtbig$) % "

    ")'docme!t#rite$"

    @mall: " % txtsmall$) % "

    ")'

    docme!t#rite$"

    +old: " % txtbold$) % "

    ")'docme!t#rite$"

    ,talic: " % txtitalics$) % "

    ")'

    docme!t#rite$"

    Fixed: " % txt0ixed$) % "

    ")'docme!t#rite$"

    @trie: " % txtstrie$) % "

    ")'

    docme!t#rite$"

    Fo!tcolor: " % txt0o!tcolor$"gree!") % "

    ")'
  • 8/13/2019 Java Script Full Metirial Part1

    94/118

    docme!t#rite$"

    Fo!tsiVe: " % txt0o!tsiVe$?) % "

    ")'

    docme!t#rite$"

    @bscript: " % txtsb$) % "

    ")'docme!t#rite$"

    @perscript: " % txtsp$) % "

    ")'

    docme!t#rite$"

    .i!: " % txtli!$"http://####schoolscom") % "

    ")'

    docme!t#rite$"

    +li!: " % txtbli!$) % " $does !ot #or i! ,*3 hrome3 or @a0ari)

    ")'

    $turn the poition of the firt occurrence of the String & inde'!f()

    var str="-ello #orld;"'docme!t#rite$stri!dex60$"d") % "
    ")'docme!t#rite$stri!dex60$"W6.&") % "
    ")'docme!t#rite$stri!dex60$"#orld"))'

    Search the te't in a String return the te't if found & match()

    var str="-ello #orld;"'docme!t#rite$strmatch$"#orld") % "
    ")'docme!t#rite$strmatch$"World") % "
    ")'docme!t#rite$strmatch$"#orlld") % "
    ")'docme!t#rite$strmatch$"#orld;"))'

  • 8/13/2019 Java Script Full Metirial Part1

    95/118

  • 8/13/2019 Java Script Full Metirial Part1

    96/118

  • 8/13/2019 Java Script Full Metirial Part1

    97/118

    Rse get&ay$) a!d a! array to #rite a #eeday3 a!d !ot jst a !mber

    var d=!e# &ate$)'var #eeday=!e# Crray$)'#eeday4N="@!day"'#eeday1N="Mo!day"'

    #eeday(N="esday"'#eedayN="Wed!esday"'#eeday7N="hrsday"'#eeday8N="Friday"'#eeday?N="@atrday"'

    docme!t#rite$"oday is " % #eedaydget&ay$)N)'

    &isplay a cloc

    0!ctio! startime$)var today=!e# &ate$)'var h=todayget-ors$)'var m=todaygetMi!tes$)'var s=todayget@eco!ds$)'

    http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_date_weekdayhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_clockhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_date_weekdayhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_timing_clock
  • 8/13/2019 Java Script Full Metirial Part1

    98/118

    // add a Vero i! 0ro!t o0 !mbers

  • 8/13/2019 Java Script Full Metirial Part1

    99/118

    var mycars = !e# Crray$)'mycars4N = "@aab"'mycars1N = "olvo"'mycars(N = "+MW"'

    0or $i=4'i

  • 8/13/2019 Java Script Full Metirial Part1

    100/118

  • 8/13/2019 Java Script Full Metirial Part1

    101/118

  • 8/13/2019 Java Script Full Metirial Part1

    102/118

  • 8/13/2019 Java Script Full Metirial Part1

    103/118

  • 8/13/2019 Java Script Full Metirial Part1

    104/118

  • 8/13/2019 Java Script Full Metirial Part1

    105/118

    Cdd !e# eleme!ts to the begi!!i!g o0 a! array X !shi0t$)

    var 0rits = "+a!a!a"3 "6ra!ge"3 "Cpple"3 "Ma!go"N'docme!t#rite$0rits!shi0t$"Hi#i") % "
    ")'

    docme!t#rite$0rits!shi0t$".emo!"3"Pi!eapple") % "
    ")'docme!t#rite$0rits)'

    Bote: he !shi0t$) method does !ot #or properly i! ,!ter!et *xplorer3 it o!ly retr!s!de0i!ed;

    +oolean $bject

    hec +oolea! vale

    var b1=!e# +oolea!$ 4)'

    var b(=!e# +oolea!$1)'var b=!e# +oolea!$"")'var b7=!e# +oolea!$!ll)'var b8=!e# +oolea!$BaB)'var b?=!e# +oolea!$"0alse")'

    docme!t#rite$"4 is boolea! "% b1 %"
    ")'docme!t#rite$"1 is boolea! "% b( %"
    ")'

    http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_unshifthttp://www.w3schools.com/js/tryit.asp?filename=tryjs_booleanhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_unshifthttp://www.w3schools.com/js/tryit.asp?filename=tryjs_boolean
  • 8/13/2019 Java Script Full Metirial Part1

    106/118

    docme!t#rite$"C! empty stri!g is boolea! "% b % "
    ")'docme!t#rite$"!ll is boolea! "% b7% "
    ")'docme!t#rite$"BaB is boolea! "% b8 %"
    ")'docme!t#rite$"he stri!g 90alse9 is boolea! "% b? %"
    ")'

    /ath $bject

    Rse ro!d$) to ro!d a !mber

    docme!t#rite$Mathro!d$4?4) % "
    ")'docme!t#rite$Mathro!d$484) % "
    ")'docme!t#rite$Mathro!d$47Q) % "
    ")'docme!t#rite$Mathro!d$X774) % "
    ")'docme!t#rite$Mathro!d$X7?4))'

    Rse ra!dom$) to retr! a ra!dom !mber bet#ee! 4 a!d 1

    //retr! a ra!dom !mber bet#ee! 4 a!d 1docme!t#rite$Mathra!dom$) % "
    ")'

    //retr! a ra!dom i!teger bet#ee! 4 a!d 14docme!t#rite$Math0loor$Mathra!dom$)K11))'

    http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_roundhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_randomhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_roundhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_random
  • 8/13/2019 Java Script Full Metirial Part1

    107/118

    Rse max$) to retr! the !mber #ith the highest vale o0 t#o speci0ied !mbers

    docme!t#rite$Mathmax$8314) % "
    ")'docme!t#rite$Mathmax$43184343(43) % "
    ")'docme!t#rite$Mathmax$X8314) % "
    ")'docme!t#rite$Mathmax$X83X14) % "
    ")'

    docme!t#rite$Mathmax$183(8))'

    docme!t#rite$Mathmi!$8314) % "
    ")'docme!t#rite$Mathmi!$43184343(43) % "
    ")'docme!t#rite$Mathmi!$X8314) % "
    ")'docme!t#rite$Mathmi!$X83X14) % "
    ")'docme!t#rite$Mathmi!$183(8))'

    o!vert elsis to Fahre!heit

    http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_maxhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_celsiushttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_maxhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_celsius
  • 8/13/2019 Java Script Full Metirial Part1

    108/118

    0!ctio! co!vert$degree)

    i0 $degree=="")F=docme!tget*leme!t+y,d$"c")vale K Q / 8 % ('docme!tget*leme!t+y,d$"0")vale=Mathro!d$F)'2else=$docme!tget*leme!t+y,d$"0")vale X() K 8 / Q'docme!tget*leme!t+y,d$"c")vale=Mathro!d$)'22

    ,!sert a !mber i!to o!e o0 the i!pt 0ields belo#: degrees elsis
    eLals
    degrees Fahre!heit

    Bote that the Mathro!d$) method is sed3 so that the reslt #ill be retr!ed as a!i!teger

    Oeneral

    Rse a 0ori! stateme!t to loop throgh the eleme!ts o0 a! object

    var perso!=0!ame:"Aoh!"3l!ame:"&oe"3age:(82'

    0or $x i! perso!)

    http://www.w3schools.com/js/tryit.asp?filename=tryjs_object_for_inhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_object_for_in
  • 8/13/2019 Java Script Full Metirial Part1

    109/118

  • 8/13/2019 Java Script Full Metirial Part1

    110/118

  • 8/13/2019 Java Script Full Metirial Part1

    111/118

    Previous Next Chapter

    JavaScript%rowser b

  • 8/13/2019 Java Script Full Metirial Part1

    112/118

    /ore Screen object examples in our JavaScript re#erence%

    -istor) $bject

    Heturn the number o# GH0s in the histor) listCreate a back button on a page

    Create a #orward button on a page0oad a speci#ic GH0 #rom the histor) list

    /ore -istor) object examples in our JavaScript re#erence%

    0ocation $bject

    Heturn the hostname and port o# the current GH0Heturn the entire GH0 o# the current pageHeturn the path name o# the current GH0Heturn the protocol portion o# the current GH00oad a new document

    Heload the current documentHeplace the current document+reak out o# a #rame

    /ore 0ocation object examples in our JavaScript re#erence%

    Previous Next Chapter

    JavaScriptHTML 1M!xamples Previous Next Chapter

    !xamples o# using JavaScript to access and manipulate the -./0 E$/ objects%

    Eocument $bject

    &rite text to the output with document%write23&rite #ormatted text to the output with document%write23

    Heturn the number o# anchors in a documentHeturn the inner-./0 o# the #irst anchor in a documentHeturn the number o# #orms in a documentHeturn the name o# the #irst #orm in a documentHeturn the number o# images in a documentHeturn the id o# the #irst image in a documentHeturn the number o# links in a documentHeturn the id o# the #irst link in a documentHeturn all nameAvalue pairs o# cookies in a documentHeturn the domain name o# the server that loaded the document

    http://www.w3schools.com/jsref/obj_screen.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_his_lengthhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_his_backhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_his_forwardhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_his_gohttp://www.w3schools.com/jsref/obj_history.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_hosthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_hrefhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_pathnamehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_protocolhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_assignhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_reloadhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_replacehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_breakouthttp://www.w3schools.com/jsref/obj_location.asphttp://www.w3schools.com/js/js_ex_objects.asphttp://www.w3schools.com/js/js_ex_dom.asphttp://www.w3schools.com/js/js_ex_browser.asphttp://www.w3schools.com/js/js_quiz.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_texthttp://www.w3schools.com/js/tryit.asp?filename=tryjs_formattexthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_anchorshttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_anchors2http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_formshttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_forms2http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_imageshttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_images2http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_linkshttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_links2http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_cookiehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_domainhttp://www.w3schools.com/jsref/obj_screen.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_his_lengthhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_his_backhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_his_forwardhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_his_gohttp://www.w3schools.com/jsref/obj_history.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_hosthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_hrefhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_pathnamehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_protocolhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_assignhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_reloadhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_loc_replacehttp://www.w3schools.com/js/tryit.asp?filename=tryjs_breakouthttp://www.w3schools.com/jsref/obj_location.asphttp://www.w3schools.com/js/js_ex_objects.asphttp://www.w3schools.com/js/js_ex_dom.asphttp://www.w3schools.com/js/js_ex_browser.asphttp://www.w3schools.com/js/js_quiz.asphttp://www.w3schools.com/js/tryit.asp?filename=tryjs_texthttp://www.w3schools.com/js/tryit.asp?filename=tryjs_formattexthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_anchorshttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_anchors2http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_formshttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_forms2http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_imageshttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_images2http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_linkshttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_links2http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_cookiehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_domain
  • 8/13/2019 Java Script Full Metirial Part1

    113/118

    Heturn the date and time the document was last modi#iedHeturn the GH0 o# the document that loaded the current documentHeturn the title o# a documentHeturn the #ull GH0 o# a document$pen an output stream, and add some text$pen an output stream in a new window, and add some textEi##erence between write23 and writeln23

    (lert inner-./0 o# an element with a speci#ic E(lert the number o# elements with a speci#ic name(lert the number o# elements with a speci#ic tagname

    /ore Eocument object examples in our JavaScript re#erence%

    (nchor $bject

    Heturn and set the value o# the charset attribute o# a linkHeturn the value o# the hre# attribute o# a linkHeturn and set the value o# the hre#lang attribute o# a linkHeturn the name o# an anchor

    Heturn the relationship between the current document and the linked documentChange the target attribute o# a linkHeturn the value o# the t)pe attribute o# a link

    /ore (nchor object examples in our JavaScript re#erence%

    (rea $bject

    Heturn the alternate text #or an area in an image5mapHeturn the coordinates o# an area in an image5mapHeturn the anchor part o# the hre# attribute o# an areaHeturn the hostnameport #or an area in an image5mapHeturn the hostname #or an area in an image5map

    Heturn the port #or an area in an image5mapHeturn the hre# o# an area in an image5mapHeturn the pathname #or an area in an image5mapHeturn the protocol #or an area in an image5mapHeturn the Iuer)string part o# the hre# attribute o# an areaHeturn the shape o# an area in an image5mapHeturn the value o# the target attribute #or an area in an image5map

    /ore (rea object examples in our JavaScript re#erence%

    +ase $bject

    Heturn the base GH0 #or all relative GH0s on a pageHeturn the base target #or all links on a page

    /ore +ase object examples in our JavaScript re#erence%

    +utton $bject

    Set a button to disabled when clickedHeturn the name o# a button

    http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_lastmodifiedhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_referrerhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_titlehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_urlhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_openhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_open2http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_writelnhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementbyidhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementsbynamehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementsbytagnamehttp://www.w3schools.com/jsref/dom_obj_document.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_charsethttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_hrefhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_hreflanghttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_namehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_relhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_targethttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_typehttp://www.w3schools.com/jsref/dom_obj_anchor.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_althttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_coordshttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_hashhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_hosthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_hostnamehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_porthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_hrefhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_pathnamehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_protocolhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_searchhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_shapehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_targethttp://www.w3schools.com/jsref/dom_obj_area.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_base_hrefhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_base_targethttp://www.w3schools.com/jsref/dom_obj_base.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_button_disabledhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_button_namehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_lastmodifiedhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_referrerhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_titlehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_urlhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_openhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_open2http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_writelnhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementbyidhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementsbynamehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_getelementsbytagnamehttp://www.w3schools.com/jsref/dom_obj_document.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_charsethttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_hrefhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_hreflanghttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_namehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_relhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_targethttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_anchor_typehttp://www.w3schools.com/jsref/dom_obj_anchor.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_althttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_coordshttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_hashhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_hosthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_hostnamehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_porthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_hrefhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_pathnamehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_protocolhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_searchhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_shapehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_area_targethttp://www.w3schools.com/jsref/dom_obj_area.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_base_hrefhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_base_targethttp://www.w3schools.com/jsref/dom_obj_base.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_button_disabledhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_button_name
  • 8/13/2019 Java Script Full Metirial Part1

    114/118

    Heturn the t)pe o# a buttonHeturn the text displa)ed on a buttonHeturn the id o# the #orm a button belongs to

    /ore +utton object examples in our JavaScript re#erence%

    "orm $bject

    Heturn the value o# each element in a #ormHeturn the value o# the accept5charset attribute in a #ormHeturn the value o# the action attribute in a #ormHeturn the value o# the enct)pe attribute in a #ormHeturn the number o# elements in a #ormHeturn the method #or sending #orm dataHeturn the name o# a #ormHeturn the value o# the target attribute in a #ormHeset a #ormSubmit a #orm

    /ore "orm object examples in our JavaScript re#erence%

    "rameA"rame $bjects

    (lign an i#rameChange the background color o# the document contained in an i#rameHeturn the value o# the #rameborder attribute in an i#rameHemove #rameborder o# an i#rameChange the height and width o# an i#rameHeturn the value o# the longdesc attribute in an i#rameHeturn the value o# the marginheight attribute in an i#rameHeturn the value o# the marginwidth attribute in an i#rameHeturn the value o# the name attribute in an i#rame

    Heturn and set the value o# the scrolling attribute in an i#rameChange the src attribute o# an i#rame

    /ore "rameA"rame object examples in ourJavaScript re#erence%

    mage $bject

    (lign an imageHeturn the alternate text o# an image(dd border to an imageChange the height and width o# an imageSet the hspace and vspace properties o# an image

    Heturn the value o# the longdesc attribute o# an imageCreate a link to a low5resolution version o# an imageHeturn the name o# an imageChange the src o# an imageHeturn the value o# the usemap attribute o# a client5side image5map

    /ore mage object examples in ourJavaScript re#erence%

    !vent $bject

    http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_button_typehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_button_valuehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_button_formhttp://www.w3schools.com/jsref/dom_obj_pushbutton.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_elementshttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_acceptcharsethttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_actionhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_enctypehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_lengthhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_methodhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_namehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_targethttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_resethttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_submithttp://www.w3schools.com/jsref/dom_obj_form.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_alignhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_contentdocumenthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_frameborderhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_frameborder2http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_heighthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_longdeschttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_marginheighthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_marginwidthhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_namehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_scrollinghttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_srchttp://www.w3schools.com/jsref/dom_obj_frame.asphttp://www.w3schools.com/jsref/dom_obj_frame.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_alignhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_althttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_borderhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_heighthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_hspacehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_longdeschttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_lowsrchttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_namehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_srchttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_usemaphttp://www.w3schools.com/jsref/dom_obj_image.asphttp://www.w3schools.com/jsref/dom_obj_image.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_button_typehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_button_valuehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_button_formhttp://www.w3schools.com/jsref/dom_obj_pushbutton.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_elementshttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_acceptcharsethttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_actionhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_enctypehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_lengthhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_methodhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_namehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_targethttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_resethttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_submithttp://www.w3schools.com/jsref/dom_obj_form.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_alignhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_contentdocumenthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_frameborderhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_frameborder2http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_heighthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_longdeschttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_marginheighthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_marginwidthhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_namehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_scrollinghttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_srchttp://www.w3schools.com/jsref/dom_obj_frame.asphttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_alignhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_althttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_borderhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_heighthttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_hspacehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_longdeschttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_lowsrchttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_namehttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_srchttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_img_usemaphttp://www.w3schools.com/jsref/dom_obj_image.asp
  • 8/13/2019 Java Script Full Metirial Part1

    115/118

    &hich mouse button was clicked1&hat is the ke)code o# the ke) pressed1&hat are the coordinates o# the cursor1&hat are the coordinates o# the cursor, relative to the screen1&as the shi#t ke) pressed1&hich element was clicked1&hich event t)pe occurred1

    $ption and Select $bjects

    Eisable and enable a dropdown listOet the id o# the #orm that contains the dropdown listOet the number o# options in the dropdown list.urn the dropdown list into a multiline listSelect multiple options in a dropdown list(lert the selected option in a dropdown list(lert the index o# the selected option in a dropdown listChange the text o# the selected optionHemove options #rom a dropdown list

    .able, .able-eader, .ableHow, .ableEata $bjects

    Change the width o# a table borderChange the cellPadding and cellSpacing o# a tableSpeci#) #rames o# a tableSpeci#) rules #or a tablenner-./0 o# a rownner-./0 o# a cellCreate a caption #or a tableEelete rows in a table(dd rows to a table(dd cells to a table row

    (lign the cell content in a table rowMertical align the cell content in a table row(lign the cell content in a single cellMertical align the cell content in a single cellChange the content o# a table cellChange the colspan o# a table row

    Previous Next Chapter

    JavaScriptAuiC Test Previous Next Chapter

    'ou can test )our JavaScript skills with &Schools8 Wui?%

    http://www.w3schools.com/js/tryit.asp?filename=try_dom_event_buttonhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_keycodehttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_clientxyhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_screenxyhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_shiftkeyhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_srcelementhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_typehttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_disabledhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_formhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_lengthhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_sizehttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_multiplehttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_optionshttp://www.w3schools.com/js/tryit.asp?filename=try_dom_option_indexhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_option_settexthttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_removehttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_borderhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_paddspachttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_framehttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_ruleshttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_rowshttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_cellshttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_createcaptionhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_deleterowhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_insertrowhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablerow_insertcellhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablerow_alignhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablerow_valignhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablecell_alignhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablecell_valignhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablerow_cellshttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablecell_colspanhttp://www.w3schools.com/js/js_ex_browser.asphttp://www.w3schools.com/js/js_quiz.asphttp://www.w3schools.com/js/js_ex_dom.asphttp://www.w3schools.com/js/js_exam.asphttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_buttonhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_keycodehttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_clientxyhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_screenxyhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_shiftkeyhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_srcelementhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_event_typehttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_disabledhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_formhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_lengthhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_sizehttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_multiplehttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_optionshttp://www.w3schools.com/js/tryit.asp?filename=try_dom_option_indexhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_option_settexthttp://www.w3schools.com/js/tryit.asp?filename=try_dom_select_removehttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_borderhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_paddspachttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_framehttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_ruleshttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_rowshttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_cellshttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_createcaptionhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_deleterowhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_table_insertrowhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablerow_insertcellhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablerow_alignhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablerow_valignhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablecell_alignhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablecell_valignhttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablerow_cellshttp://www.w3schools.com/js/tryit.asp?filename=try_dom_tablecell_colspanhttp://www.w3schools.com/js/js_ex_browser.asphttp://www.w3schools.com/js/js_quiz.asphttp://www.w3schools.com/js/js_ex_dom.asphttp://www.w3schools.com/js/js_exam.asp
  • 8/13/2019 Java Script Full Metirial Part1

    116/118

    .he .est

    .he test contains :< Iuestions and there is no time limit%

    .he test is not o##icial, it8s just a nice wa) to see how much )ou know, or don8t know, about JavaScript%

    Count 'our Score

    'ou will get = point #or each correct answer% (t the end o# the Wui?, )our total score will be displa)ed% /aximumscore is :< points%

    Oood luck4 Start the JavaScript Wui?

    Previous Next Chapter

    JavaScript and -./0 E$/2eerence &Schools -ome Next He#erence

    .his section contains a complete re#erence o#

    (ll built5in JavaScript objects

    (ll browser objects

    (ll -./0 E$/ objects

    JavaScript $bjects He#erence

    .he re#erences describe the properties and methods o# each object, along with examples%

    (rra) object +oolean object

    Eate object

    /ath object

    Number object

    String object

    Heg!xp object

    Olobal properties and #unctions

    http://www.w3schools.com/quiztest/quiztest.asp?qtest=JavaScripthttp://www.w3schools.com/js/js_ex_dom.asphttp://www.w3schools.com/js/js_exam.asphttp://www.w3schools.com/default.asphttp://www.w3schools.com/jsref/jsref_obj_array.asphttp://www.w3schools.com/jsref/jsref_obj_array.asphttp://www.w3schools.com/jsref/jsref_obj_boolean.asphttp://www.w3schools.com/jsref/jsref_obj_date.asphttp://www.w3schools.com/jsref/jsref_obj_math.asphttp://www.w3schools.com/jsref/jsref_obj_number.asphttp://www.w3schools.com/jsref/jsref_obj_string.asphttp://www.w3schools.com/jsref/jsref_obj_regexp.asphttp://www.w3schools.com/jsref/jsref_obj_global.asphttp://www.w3schools.com/quiztest/quiztest.asp?qtest=JavaScripthttp://www.w3schools.com/js/js_ex_dom.asphttp://www.w3schools.com/js/js_exam.asphttp://www.w3schools.com/default.asphttp://www.w3schools.com/jsref/jsref_obj_array.asphttp://www.w3schools.com/jsref/jsref_obj_array.asphttp://www.w3schools.com/jsref/jsref_obj_boolean.asphttp://www.w3schools.com/jsref/jsref_obj_date.asphttp://www.w3schools.com/jsref/jsref_obj_math.asphttp://www.w3schools.com/jsref/jsref_obj_number.asphttp://www.w3schools.com/jsref/jsref_obj_string.asphttp://www.w3schools.com/jsref/jsref_obj_regexp.asphttp://www.w3schools.com/jsref/jsref_obj_global.asp
  • 8/13/2019 Java Script Full Metirial Part1

    117/118

  • 8/13/2019 Java Script Full Metirial Part1

    118/118

    &Schools -ome Next He#erence

    http://www.w3schools.com/default.asphttp://www.w3schools.com/jsref/jsref_obj_array.asphttp://www.w3schools.com/default.asphttp://www.w3schools.com/jsref/jsref_obj_array.asp