Exploring Java Script n n n Java Script




- Slides: 4

Exploring Java. Script n n n Java. Script is a scripting language used to add animation and interactivity to a Web page. The HTML <SCRIPT>…</SCRIPT> tags are used to identify a Java. Script program. Java. Script has multiple invisible entities called objects which can be manipulated and accessed from a Java. Script program. Java. Script objects have “methods” that can be called to perform operations on the object. Java. Script includes conditional statements that can be used to customize the operation of the program. Programming Basics - Unit 4

Conditional statements can be used to alter or customize Java. Script program flow <HTML> <HEAD> <TITLE>Java. Script Activity #3</TITLE> If tested condition is true, </HEAD> <BODY> execute this line, else, if <<SCRIPT>>> condition is false, if (navigator. app. Name == "Netscape") execute these two lines. { document. write("You are using Netscape Navigator. "); } else { document. write("You are not using Netscape Navigator. <<BR>>>"); document. write("I’ll bet you’re using Internet Explorer. "); } <</SCRIPT>>> </BODY> </HTML> Programming Basics - Unit 4

Use Images with Java. Script n n n Java. Script events can be used to add animation and special effects to Web pages. User-written functions can be created to enhance Web pages. Image rollovers can be created to respond to mouse events. Cycling banners can be created using Java. Script functions. The Java. Script random-number generator can be used to display images at random. Java. Script can be used to create a user-controlled slide show. Programming Basics - Unit 4

Java. Script code to create an image rollover <SCRIPT> blue. Arrow = new Image; Images to be blue. Arrow. src = "bluearrow. gif"; rotated when red. Arrow = new Image; event occurs. red. Arrow. src = "redarrow. gif"; </SCRIPT> </HEAD> Event handling <BODY> code to swap the <CENTER> images. <A HREF="webpage. html" on. Mouse. Over="document. arrow. src = red. Arrow. src; " on. Mouse. Out="document. arrow. src = blue. Arrow. src; "> <IMG SRC="bluearrow. gif" NAME="arrow" WIDTH=320 HEIGHT=200>> </A> Programming Basics - Unit 4