HTML and CSS Reference
In-Depth Information
21
adding JavaScript
The modern Web is built on three technologies: HTML, CSS, and JavaScript. The first provides
content and structure, the second provides presentation, and the third provides interactivity and
advanced applications. JavaScript is a client-side — meaning it runs on your computer, not the
web host — scripting language. Because JavaScript is not compiled, like Java or C++, all you
need to write and read it is a text editor, just like HTML and CSS.
JavaScript is enjoying a bit of a renaissance these days, especially with the upcoming release
of HTML5. The major browsers have all revamped their JavaScript engines with a focus on
faster processing. HTML5 provides support for many JavaScript enhancements affecting
user interactivity, databases, local storage, offline applications, geolocation, audio and video
manipulation, and even drawing with the new <canvas> tag.
A comprehensive examination of all that JavaScript can do is far beyond the scope of this topic,
but this section of the topic can get you started. For any work in JavaScript on the Web, you
need to know how to include JavaScript in your web page both as directly as code and also
by referencing an external script. In this lesson, you learn how to add JavaScript code to your
page, how to prepare for website visitors who have JavaScript disabled, and how to test your
JavaScript.
undersTandin
G JaV
scriPT
T
Tandin
JaV
Ja VV
JavaScript can address aspects of the browser used to look at a web page as well as the web
page itself. With JavaScript, you can detect which browser is being used and change CSS styles
accordingly. JavaScript has control over the browser window as well and can pop up new win-
dows, resize existing ones, or close any that are open. For example, if you wanted to change
the size of the current browser window to 800 pixels wide by 600 pixels tall, you might use
this JavaScript code:
window.resizeTo(800, 600);
Search WWH ::




Custom Search