Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
So far, you’ve seen the right way to put JavaScript in a page, but you haven’t done anything impressive (in fact, you haven’t done anything but pop up a message box). Before going ahead, you need to know a bit more about the role JavaScript typically plays.
First, it’s important to understand that JavaScript code is sandboxed, which means its capabilities are carefully limited. Your page can’t perform any potentially risky tasks on your visitor’s computer, like sending orders to a printer, accessing files, running other programs, reformatting a hard drive, and so on. This design ensures good security, even for careless visitors.
Instead, JavaScript spends most of its time doing one of these tasks: