O'Reilly logo

HTML, XHTML, and CSS Bible, Fourth Edition by Steven M. Schafer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 16. Scripts

IN THIS CHAPTER

  • Client-side versus server-side scripting

  • Setting the default scripting language

  • Including a script

  • Calling an external script

  • Triggering scripts with events

  • Hiding scripts from older browsers

Standard HTML was designed to provide static, text-only documents. No innate intelligence is built into plain HTML, but it is desired, especially in more complex documents or documents designed to be interactive. Enter scripts — svelte programming languages designed to accomplish simple tasks while adhering to the basic premise of the Web, easily deployable content that can play nicely with plain-text HTML.

This chapter covers scripting basics and goes into the details of how to use client-side scripting in your documents.

Client-Side Versus Server-Side Scripting

There are two basic varieties of scripting, client-side and server-side. As their names imply, the main difference is where the scripts are actually executed.

Client-side scripting

Client-side scripts are run by the client software — that is, the user agent. As such, they impose no additional load on the server, but the client must support the scripting language being used.

JavaScript is the most popular client-side scripting language, but Jscript and VBScript are also widely used. Client-side scripts are typically embedded in HTML documents and deployed to the client. Client users can usually easily view these scripts.

For security reasons, client-side scripts generally cannot read or write to the server or client ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required