Professional Documents
Culture Documents
Javascript Tutorial.9527862.Powerpoint
Javascript Tutorial.9527862.Powerpoint
2
What you can’t do
To protect the visitor to your web pages, you can’t:
Read or write user files
However, JScript on IE allows ASP scripting, which is how the very
destructive JS.Gigger.A@mm worm spreads
To turn off active scripting in Outlook Express, see
http://support.microsoft.com/support/kb/articles/Q192/8/46.ASP
Execute any other programs
Connect to any other computer, except to download another
HTML page or to send e-mail
Determine what other sites the user has visited
Open a very small (less than 100px by 100px) window or an
offscreen window (except in IE)
3
Debugging
Mozilla/Netscape has much better debugging tools than IE
Mozilla
Select Tools => Web Development => JavaScript console
Netscape 6:
Select Tasks => Tools => JavaScript console
Netscape 4:
Select Communicator => Tools => JavaScript console
Any Mozilla or Netscape:
Type javascript: in the location bar and press Enter
Internet Explorer:
Go to the Preferences... dialog and look for something like Web
content => Show scripting error alerts
After debugging, test your program in IE
IE is the most popular browser
4
Numbers
In JavaScript, all numbers are floating point
Special predefined numbers:
Infinity, Number.POSITIVE_INFINITY -- the result of dividing a positive
number by zero
Number.NEGATIVE_INFINITY -- the result of dividing a negative number
by zero
NaN, Number.NaN (Not a Number) -- the result of dividing 0/0
NaN is unequal to everything, even itself
There is a global isNaN() function
Number.MAX_VALUE -- the largest representable number
Number.MIN_VALUE -- the smallest (closest to zero) representable
number
5
Strings and characters
In JavaScript, string is a primitive type
Strings are surrounded by either single quotes or double quotes
There is no “character” type
Special characters are:
6
Some string methods
charAt(n)
Returns the nth character of a string
concat(string1, ..., stringN)
Concatenates the string arguments to the recipient string
indexOf(substring)
Returns the position of the first character of substring in the recipient
string, or -1 if not found
indexOf(substring, start)
Returns the position of the first character of substring in the given string
that begins at or after position start, or -1 if not found
lastIndexOf(substring), lastIndexOf(substring, start)
Like indexOf, but searching starts from the end of the recipient string
7
More string methods
match(regexp)
Returns an array containing the results, or null if no match is
found
On a successful match:
groups
The array index property gives the first matched position
replace(regexp, replacement)
Returns a new string that has the matched substring replaced with
the replacement
search(regexp)
Returns the position of the first matched substring in the given
9
Interesting, right?
This is just a sneak preview of the full presentation. We hope you like
it! To see the rest of it, just
click here to view it in full on PowerShow.com. Then, if you’d like, you
can also log in to PowerShow.com to download the entire
presentation for free.