W3Schools.com

JavaScript Primer


JavaScript - Client-side Scripting

JavaScript is THE scripting language of the Web.

JavaScript is used in billions of Web pages to add functionality, validate forms, communicate with the server, and much more.

JavaScript is easy to learn.

JavaScript Example

My First Web Page

This is a paragraph.




Try it yourself »
Click on the "Try it yourself" button to see how it works


What is JavaScript?

  • JavaScript is a scripting language
  • A scripting language is a lightweight programming language
  • A JavaScript consists of lines of executable computer code
  • A JavaScript is usually embedded directly into HTML pages
  • JavaScript was designed to add interactivity to HTML pages
  • JavaScript is free. Everyone can use JavaScript without a license

Client-side Scripting

JavaScript is about "programming" the behavior of a browser. This is called client-side scripting (or browser scripting).

Server-side scripting is about "programming" the behavior of the server (see the Web ASP/PHP chapter).


What can a JavaScript Do?

  • JavaScript gives HTML designers a programming tool - JavaScript is a scripting language with a very simple syntax! Almost anyone can put small "snippets" of code into their HTML pages
  • JavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element
  • JavaScript can be used to validate data - A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing
  • JavaScript can be used to detect the visitor's browser - A JavaScript can be used to detect the visitor's browser, and load another page specifically designed for that browser
  • JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer
  • JavaScript can read/write/modify HTML elements - A JavaScript can read and change the content of an HTML element
  • JavaScript uses the HTML DOM to access the elements of a web page

What is the HTML DOM?

The HTML DOM defines a standard way for accessing and manipulating HTML documents.

The DOM presents an HTML document as a tree-structure:

HTML DOM Tree Example

DOM HTML tree



How to Learn JavaScript?

Study our Complete JavaScript Tutorial

Study our Complete HTML DOM Tutorial

Study our Complete JavaScript and HTML DOM Reference




W3Schools Certification

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE