Tuesday, April 14, 2009

JavaScript Variable

• You create a variable with or without the var
statement
var strname = some value
strname = some value
• When you declare a variable within a function, the
variable can only be accessed within that function
• If you declare a variable outside a function, all the
functions on your page can access it
• The lifetime of these variables starts when they are
declared, and ends when the page is closed13
JavaScript Popup Boxes
• Alert box
> User will have to click "OK" to proceed
> alert("sometext")
• Confirm box
> User will have to click either "OK" or "Cancel" to proceed
> confirm("sometext")
• Prompt box
> User will have to click either "OK" or "Cancel" to proceed after
entering an input value
> prompt("sometext","defaultvalue")14
JavaScript Language
• Conditional statement
> if, if.. else, switch
• Loop
> for loop, while loop
• try...catch
• throw

No comments:

Post a Comment