XP Tutorial 1 Introducing Java Script Hiding EMail












































- Slides: 44

XP Tutorial 1 Introducing Java. Script Hiding E-Mail Addresses from Spammers 1

Objectives XP • Understand the history and theory of Java. Script • Create a script element • Understand use basic Java. Script syntax • Write text to a Web document using a Java. Script command Tutorial 1 New Perspectives on Java. Script, Comprehensive 2

Objectives XP • Understand the different data types supported by Java. Script • Declare a variable and assign it a value • Reference a variable in a Java. Script statement • Create and call a Java. Script function Tutorial 1 New Perspectives on Java. Script, Comprehensive 3

Objectives XP • Access functions from an external Java. Script file • Document code with multiline and single-line comments • Understand basic techniques for debugging Java. Script code Tutorial 1 New Perspectives on Java. Script, Comprehensive 4

XP Staff Directory at Monroe Public Library Web Page Tutorial 1 New Perspectives on Java. Script, Comprehensive 5

Introduction to Java. Script XP • Spam – Junk e-mail • Spammer – Person who sends spam • E-mail harvester – Program that scans documents looking for e-mail addresses Tutorial 1 New Perspectives on Java. Script, Comprehensive 6

XP E-Mail Addresses in Staff Directory Tutorial 1 New Perspectives on Java. Script, Comprehensive 7

Server-Side and Client-Side Programming XP • Server-side programming – Program placed on server that hosts Web site – Program then used to modify contents and structure of Web pages Tutorial 1 New Perspectives on Java. Script, Comprehensive 8

Server-Side and Client-Side Programming XP • Client-side programming – Runs programs on user’s computer – Programs likely to be more responsive to users – Can never completely replace server-side programming Tutorial 1 New Perspectives on Java. Script, Comprehensive 9

Server-Side Programming Tutorial 1 New Perspectives on Java. Script, Comprehensive XP 10

Client-Side Programming Tutorial 1 New Perspectives on Java. Script, Comprehensive XP 11

XP Combining Client-Side and Server. Side Programming Tutorial 1 New Perspectives on Java. Script, Comprehensive 12

XP The Development of Java. Script • Java – Developed by Sun Microsystems – Programs designed to be run within Java interpreters – An example of a compiled language • Java. Script – Subset of Java – An interpreted language – Internet Explorer supports a version called JScript Tutorial 1 New Perspectives on Java. Script, Comprehensive 13

XP Comparing Java and Java. Script Tutorial 1 New Perspectives on Java. Script, Comprehensive 14

XP Versions of Java and Java. Script Tutorial 1 New Perspectives on Java. Script, Comprehensive 15

XP Working with the Script Element • Script element – Used to enter scripts into an HTML or XHTML file – Syntax <script type="mime-type"> script commands </script> Tutorial 1 New Perspectives on Java. Script, Comprehensive 16

XP Writing Output to a Web Document • Inserting [email protected]. gov in a Web document <script type="text/javascript"> document. write("[email protected]. gov"); </script> Tutorial 1 New Perspectives on Java. Script, Comprehensive 17

XP The document. write() Method • One way to send output to the Web document • Object – Can be any item, including mouse pointer or window scrollbars • Method – Process by which Java. Script manipulates the features of an object Tutorial 1 New Perspectives on Java. Script, Comprehensive 18

XP Understanding Java. Script Rules and the Use of White Space • Java. Script – Is case sensitive – Ignores most occurrences of extra white space – Line breaks occurring within a statement can cause error – Good practice to not break a statement into several lines Tutorial 1 New Perspectives on Java. Script, Comprehensive 19

Supporting Non-Java. Script Browsers XP • noscript element – Used by browsers that do not support scripts – Syntax <noscript> alternative content </noscript> Tutorial 1 New Perspectives on Java. Script, Comprehensive 20

Supporting Non-Java. Script Browsers XP • CDATA section – Marks text as data that should not be processed by XHTML parsers – Syntax <script type="text/javascript"> <![cdata[ Java. Script code ]]> </script> Tutorial 1 New Perspectives on Java. Script, Comprehensive 21

XP Working with Variables • Variable – A named item in a program that stores information – Used to represent values and text strings – Values can change as the program runs Tutorial 1 New Perspectives on Java. Script, Comprehensive 22

Declaring a Variable XP • Tells Java. Script interpreter to reserve memory space for the variable • Statement to declare a variable; • Declaring three variables var em. Link, user. Name, em. Server; Tutorial 1 New Perspectives on Java. Script, Comprehensive 23

Declaring a Variable XP • Limits on variable names – First character must be either a letter or an underscore character ( _ ) – Remaining characters can be letters, numbers, or underscore characters – Variable names cannot contain spaces – Reserved words cannot be used Tutorial 1 New Perspectives on Java. Script, Comprehensive 24

XP Assigning a Value to a Variable • variable = value; • Combining variable declaration and assignment in a single statement var user. Name = "cadler", em. Server = "mpl. gov"; Tutorial 1 New Perspectives on Java. Script, Comprehensive 25

Working with Data Types XP • Data type – Type of information stored in a variable • Numeric value – Any number, such as 13, 22. 5, or -3. 14159 • Text string – Any group of text characters, such as “Hello” • Boolean value – Indicates the truth or falsity of a statement Tutorial 1 New Perspectives on Java. Script, Comprehensive 26

XP Working with Data Types • Null value – Value has not yet been assigned to variable • Weakly typed language – Variables are not strictly tied to specific data types • Strongly typed languages – Force programmer to explicitly identify a variable’s data type Tutorial 1 New Perspectives on Java. Script, Comprehensive 27

XP Writing a Variable Value to a Web Document • Variable – Can be used in place of value it contains • Writing a text string to a Web page var lib. Name = "Monroe Public Library"; document. write(lib. Name); • Plus symbol ( + ) – Can be used to combine variable with text string Tutorial 1 New Perspectives on Java. Script, Comprehensive 28

XP Creating a Function to Perform an Action • Functions – Collection of commands that perform an action or return a value – Include a function name – Include a set of commands that run when function is called – Some require parameters Tutorial 1 New Perspectives on Java. Script, Comprehensive 29

XP Creating a Function to Perform an Action • Syntax of a Java. Script function_name(parameters){ Java. Script commands } • Calling a function_name(parameter values) Tutorial 1 New Perspectives on Java. Script, Comprehensive 30

XP Functions and Variable Scope • Variable scope – Indicates where and how the variable can be used in your application – Can be local or global Tutorial 1 New Perspectives on Java. Script, Comprehensive 31

XP Functions and Variable Scope • Local scope – Variable created within a Java. Script function • Global scope – Variables not declared within functions Tutorial 1 New Perspectives on Java. Script, Comprehensive 32

XP Creating a Function to Return a Value • For a function to return a value – It must include a return statement • Syntax of a function that returns a value function_name(parameters) { Java. Script commands return value; } Tutorial 1 New Perspectives on Java. Script, Comprehensive 33

XP Accessing an External Java. Script File • Common practice to – Create libraries of functions located in external files • Script elements that point to external files are – Placed in a document’s head section • Extension “. js” – Used by external files containing Java. Script commands and functions Tutorial 1 New Perspectives on Java. Script, Comprehensive 34

Using an External Script Tutorial 1 New Perspectives on Java. Script, Comprehensive XP 35

XP Commenting Java. Script Code • Comments – Explain what your programs are designed to do and how they work • Multiline comment /* The show. EM() function displays a link to the user’s e-mail address. The username and e-mail server name are entered in reverse order */ Tutorial 1 New Perspectives on Java. Script, Comprehensive 36

Using Comments to Hide Java. Script Code XP • Syntax for hiding script <script type="text/javascript"> <!-- Hide from non-Java. Script browsers Java. Script commands // Stop hiding from older browsers --> </script> Tutorial 1 New Perspectives on Java. Script, Comprehensive 37

Debugging Your Java. Script Programs XP • Load-time error – Occurs when script is first loaded by Java. Script interpreter • Run-time error – Occurs after script has been successfully loaded and is being executed • Logical errors – Free from syntax and structural mistakes, but result in incorrect results Tutorial 1 New Perspectives on Java. Script, Comprehensive 38

Displaying a Logical Error Tutorial 1 New Perspectives on Java. Script, Comprehensive XP 39

Common Mistakes XP • Debugging – Process of searching code to locate a source of trouble • Common errors – – Tutorial 1 Misspelling a variable name Mismatched parentheses or braces Mismatched quotes Missing quotes New Perspectives on Java. Script, Comprehensive 40

XP Debugging Tools and Techniques • Writing modular code – Breaking up a program’s different tasks into smaller, more manageable chunks • Alert dialog box – Dialog box generated by Java. Script that displays a text message with an OK button • Microsoft Script Debugger – Can help to create and debug Java. Script programs Tutorial 1 New Perspectives on Java. Script, Comprehensive 41

Microsoft Debugger Window Tutorial 1 New Perspectives on Java. Script, Comprehensive XP 42

XP Tips for Writing Good Java. Script Code • Apply layout techniques to make code more readable • Use descriptive variable names • Be consistent in how you apply uppercase and lowercase letters to your variable names • Add comments to your code Tutorial 1 New Perspectives on Java. Script, Comprehensive 43

XP Tips for Writing Good Java. Script Code • Create customized functions • Break up long and complicated functions into smaller functions • Use the debugging tools available • In case of a logical error, use alert boxes Tutorial 1 New Perspectives on Java. Script, Comprehensive 44
Java script email
Informal email
Greasemonkey scripts
Script de java
Data types in javascript
Java script wikipedia
"java script"
"java script"
"java script"
Java script course
Java script
"java script"
Khan academy java programming
Java script examples
Inside which html element do we put
Java script ide
"java script"
Riad wahby
Java script classes
Java mail gmail
What is the purpose of a signal phrase
Introducing phonetics and phonology answer key
1941-1882
Quote analysis sentence starters
Argumentative essay counterclaim
Introduce yourself sample
How to introduce yourself in training session
Ma
Ottava rima poem examples
Introduction about digestive system
Introduction of company background
Opposite numbers definition
Mpls vpn internet access
Quote citation
Introducing new market offerings ppt
Templates for introducing quotations
Define upgrade advisor
Khdmdcm conversion
How to write a biography about myself
Relocation diffusion definition
Blood relation chart
The odyssey and epic poetry: an introduction, part 1
Exchange letter format
Carrying broker
Int family