In Unit 5 of this course
you'll learn how web developers use scripting to make their websites more interactive.
On today's web, you can shop online...
Bank online...
Watch videos...
Listen to music...
Share photos...
Chat with friends...
Play interactive games...
Contribute to the world's collective knowledge...
...and on and on.
The level of interactivity on today's web
would not be possible if we were limited to using HTML and CSS.
So, we reply on scripts.
Scripts are computer programs that are written in a variety of different scripting languages.
There are two general types of scripts for the web, server-side and client-side.
Server-side scripts are executed on the server, before the web page is delivered to the user.
This allows web pages to be custom built with every request.
In the first module of this unit you will learn about a variety of server-side technologies
that are working hard behind the scenes
to assemble and deliver a web page to you whenever you enter a web address into your browser.
In contrast, client-side scripts are executed in the browser, after the web page is already delivered.
The most common client-side scripting language is JavaScript,
and for most of this unit you will be learning the basics of writing JavaScript code.
Your first scripting activity will be to display a simple alert that appears automatically when the page is loaded.
But you probably don't want an alert to pop up every time a user loads a page.
That would be annoying.
So you'll learn how to show the alert only when a user performs some action,
for example, clicking on a button.
From there, you'll continue to expand your knowledge of JavaScript by building a digital clock.
This activity involves all the skills you've learned so far in this course, starting with HTML.
Even though you'll be building the clock using JavaScript,
the clock is actually just hours and minutes, separated by a colon.
It's just HTML – nothing fancy.
If you want it to look like a clock, you can do that with CSS.
For example... We want our clock to have large easy-to-read numbers.
So we'll increase font size and make the type bold as well.
Of course, a clock isn't really a clock unless it keeps accurate time.
This is where JavaScript comes in.
The activities in this unit will provide you with all the code you need to update the time...
Add leading zeros if hours or minutes are less than 10; plus add "am" or "pm"...
And continually update the time every second.
You'll also learn to use JavaScript to show... and hide... content on the page.
In the end, you'll have a fully functional – and very cool – digital clock.
But more importantly...
you'll have gained some valuable experience using JavaScript in conjunction with HTML and CSS.