Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Javascrbipt Intro Javascript (or js) is a programming language. Interpreted, not compiled. Not the same as java, but, similar. Use tags to use. Object-oriented.

Similar presentations


Presentation on theme: "1 Javascrbipt Intro Javascript (or js) is a programming language. Interpreted, not compiled. Not the same as java, but, similar. Use tags to use. Object-oriented."— Presentation transcript:

1 1 Javascrbipt Intro Javascript (or js) is a programming language. Interpreted, not compiled. Not the same as java, but, similar. Use tags to use. Object-oriented – data encapsulated. Should write code within HTML comments.

2 2 Some Objects document – The page we are viewing. navigator – The browser we are using. window – The current window. To make an object do something, or set an attribute do the following: –object.do_something(); –object.set_attribute (value); –object.attribute=value;

3 3 Examples document.bgColor = “red” sets the background color to red. document.writeln(“Text String”); writes out the text string to the screen with a newline. document.write(“Text String”); prints out text string just as is.

4 4 Interactivity ONMOUSEOVER – lets you cause things to happen when people mouse over certain places on the page. red -- will make the background red when you mouse over the word “red”.

5 5 Forms and Scripts Forms let you enter data and then do something with it. A function is a piece of computer code that does something like manipulating data. Your form can call a script when it is done, or when certain data is entered.

6 6 Forms and Scripts Make a function inside of tags at the top of your webpage. Write a form that calls the function when things are entered. –

7 7 Functions printmessage is a function. –A name given to a sequence of program steps that do something 1 is an argument or parameter, a piece of data passed to the function so it can do different things based on different numbers being entered.

8 8 Functions 2 function printresponse (num) { if (num == 1) alert (“It is 1.”); else alert (“It is not 1.”); }

9 9 Variables A variable is a data location or a name for a piece of data you will use in a program. To declare a variable called name, type a line with the words –var name; You don’t need to specify a variable type like you do in a lot of other languages.

10 10 Math operations Variables can be modified like in regular math and algebra operations. The left-hand side is the location where the result is stored, and everything on the right hand side is the formula to be evaluated. Variables can appear on both sides of the equation.

11 11 If statements You can check whether two values are larger or smaller than one another using if statements. The format is If (leftside comparison rightside) Leftside and rightside are algebraic expressions or numbers. Inequality examples: == != = > <

12 12 Looping A loop repeats code a certain number of times, except that each time, the code can do slightly different things. Example: var count; for (count = 0; count < 10; count++) document.writeln (count + “ ”);


Download ppt "1 Javascrbipt Intro Javascript (or js) is a programming language. Interpreted, not compiled. Not the same as java, but, similar. Use tags to use. Object-oriented."

Similar presentations


Ads by Google