Javascript is a lightweight progr language, typically used to animate certain behaviors, create cookies, validate data, generate html ...
<script type="text/javascript"> must envelop JS cmds and can appear in &<head> and <body> tags. Declaring function in the head section ensures that it will be loaded and accessible when function calls are placed from within the <body> section.
External scripts declaration goes in head tag: <script src="external-script-file.js">
May need to envelope scripting command in comments for browsers not supporting JS.
Many of the same programming constructs as C and Java is supported. Only new, unfamiliar relational operator is '==='. It checks for equality in value and type.
While JS is said to be an object-oriented progr lang, it doesn't appear to support inheritance, polymorphism, etc. It does support however object decl and creation, environment defined classes, system libraries with useful methods. User defined classes supported. Its not clear whether constructors are needed. Function overload doesn't appear to be supported.
Many different types of events are recognized, too many to remember. Some of them are:
mouseclick, web page or image loading, mousing over hot spot, selecting input block in HTML form, submitting an HTL form, tracking keystrokes.
There were three types of functions that throw up dialog boxes: { alert, confirm, prompt }.
alert() has no return type, confirm returns boolean, and prompt supports a return value.
Try, Catch construct supported, w/ Error object being available as a Catch argument.
User generated exception can be thrown too.
Many string methods available that can be used to style text. big(), small(), bold(), toLowercase, toUpperCase, link() are a few examples:
For example: String object instance:
var mystring="I am an hyperlink";
mystring.link("http://www.w3schools.com");
There is extensive spport for Date objects and Regular expressions. Need to refamiliarize with regexpr patterns.
The HTML DOM defines a standard set of objects, and a standard way to access and manipulate.
For example: screen object properties
* availHeight
* logicalXDPI - horizontal dots/inch
Browser info avail too thru navigator object
i.e.
function detect_Browser() {
var browser = navigator.appname;
var b_version= navigator.appVersion;
var version = parseFloat(b_version); // which pulls out 1st thing resembling a decimal#.
<body onload ="detectBrowser()";
more-to-follow on {cookies, validation, and object creation} ...
Friday, October 10, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment