Skip to Main Content
Webmaster in a Nutshell, Third Edition
book

Webmaster in a Nutshell, Third Edition

by Robert Eckstein, Stephen Spainhour
December 2002
Intermediate to advanced content levelIntermediate to advanced
576 pages
32h
English
O'Reilly Media, Inc.
Content preview from Webmaster in a Nutshell, Third Edition

Client-Side JavaScript

Client-side JavaScript is the name given to JavaScript code that is embedded within an HTML file and executed by a web browser. In addition to the core objects described in the previous section, client-side JavaScript code has access to a number of other objects that represent the web browser, the document displayed in the browser, and the contents of that document. Client-side JavaScript programs are usually event-based, which means that JavaScript event handlers are executed in response to user interactions with the browser and the document. The client-side JavaScript scripting framework is powerful enough to open substantial security holes in web browsers. For this reason, web browsers typically restrict the actions of client-side scripts. This section starts by explaining how JavaScript code is embedded in HTML files, then goes on to introduce the client-side JavaScript objects, JavaScript events and event handling, and JavaScript security restrictions.

JavaScript in HTML

JavaScript code may be embedded in HTML files in the form of scripts, event handlers and URLs, as detailed below.

The <script> tag

Most JavaScript code appears in HTML files between a <script> tag and a </script> tag. For example:

<script>
document.write("The time is: " + new Date());
</script>

In JavaScript 1.1 and later you can use the src attribute of the <script> tag to specify the URL of an external script to be loaded and executed. Files of JavaScript code typically have a .js ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Webmaster in a Nutshell, Second Edition

Webmaster in a Nutshell, Second Edition

Stephen Spainhour, Robert Eckstein

Publisher Resources

ISBN: 0596003579Purchase bookErrata Page