spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / javascript / professional / chap4 / 3 current pageTo page 2To page 3To page 4
[next]

Professional JavaScript

Developer News
Google to Shake Up Browsers With Own Launch
Mozilla's Ubquity Mashup: For The Masses?
iPhone Users Just Want to Have Fun

<META>

This tag in HTML 4.0 provides a way of setting the default scripting language for an HTML document, and the default style definition language. The syntax is:

<META http-equiv="Content-Script-Type" content="text/JavaScript">
<META http-equiv="Content-Style-Type" content="text/JavaScript">

Since JavaScript is already the default, and Internet Explorer doesn't support JSSS, they're not of much use yet. Netscape 4.0 ignores the tag variants.

Events

HTML events are the main way JavaScript improves its interactivity with the user. An event is just a piece of input to the browser, usually from the user. Event handlers are bits of JavaScript code that execute in response to events.

1

An event model describes how events are created and moved around by the software. The HTML 4.0 standard calls events relating to HTML intrinsic events. These are the browser events of most interest. The components of the HTML event model are:

  • Special conditions causing events to occur.
  • Special attributes in HTML tags for each event.
  • Scripts to handle each event.
  • A JavaScript host object that a given event acts on.
  • Control passed temporarily to the JavaScript interpreter when an event occurs.
  • Data accompanying the event.

From the scriptwriter's point of view, only components 3, 4, and 5 require any JavaScript code.

Creating Handlers

There are two ways to create JavaScript for HTML events: via HTML tags and via JavaScript host objects.

<HTML><HEAD><SCRIPT>
var shouts = 0;

function shout(obj)
{
  alert('What? Just: "' + this.value + '"\n\nLOUDER !!');
}
</SCRIPT></HEAD>
<BODY>
Shouting page. Type away, then hit the TAB key.<BR>

<FORM NAME="shouter"> First shout:
<INPUT TYPE="text" NAME="first" ONCHANGE="this.value='LOUDER !!!';return true;">
<BR> Second shout:
<INPUT TYPE="text">
<BR> Last shout:
<INPUT TYPE="text" NAME="last">
</FORM>

<SCRIPT>
document.shouter[1].onchange=shout;
document.shouter.last.onchange=shout;
</SCRIPT></BODY></HTML>

In this example there are three HTML text fields, all with onChange event handlers. Since HTML tag attributes are case insensitive, ONCHANGE could have been written onchange or onChange. In documentation, the convention is to use onChange, as will be done from here on. In JavaScript code, the equivalent property must be lowercase - onchange, except Netscape 4+ will allow onChange as well. Later in this section the implications of this handler are described. For now, run the example and see for yourself, or just note the syntax.

Contents

home / programming / javascript / professional / chap4 / 3 current pageTo page 2To page 3To page 4
[next]

Copyright 1999 (1st Edition) and 2001 (2nd Edition) Wrox Press Ltd. and

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Intel PDF: Virtualization Delivers Data Center Efficiency
Intel eBook: Managing the Evolving Data Center
Microsoft Article: BitLocker Brings Encryption to Windows Server 2008
Symantec eBook: The Guide to E-Mail Archiving and Management
Microsoft Article: RODCs Transform Branch Office Security
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
Avaya Article: Advancing the State of the Art in Customer Service
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Avaya Article: Avaya AE Services Provide Rapid Telephony Integration with Facebook
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Seminar: Efficiencies in Hardware/Software Virtualization
HP Webcast: Disaster Recovery Planning
Go Parallel Video: Performance and Threading Tools for Game Developers
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
IBM TCO eKIT: Your IT Budget is Under Attack, Get in Control
IBM Energy Efficiency eKIT: Learn How to Reduce Costs
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Microsoft Article: Silverlight Streaming--Free Video Hosting for All
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
HP Demo: StorageWorks EVA4400
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
webref The latest from WebReference.com Browse >
The Partial Function Application in JavaScript · Creating Dynamic RSS Feeds with Ajax · Performance Optimizations for High Speed JavaScript
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
SQL Server 2005 Express Edition - Part 30 - Distributed Service Broker Environment - Endpoints · Google Chrome: A Shiny New Salvo in the Browser War · eBiz News: Google Streamlines Feeds to Product Search


Revised: March 21, 2001
Created: March 21, 2001


URL: http://webreference.com/programming/javascript/professional/chap4/3/