Professor: Good job. I guess you must be eager to make your Sudoku interactive, so
there’s no time to lose.
12.2 Deeper into the Browser
Professor: Our work so far focused primarily on the core JavaScript language, a nd
even though we ran all our examples within a web browser, the code itself had little to
do with the specific con text of a web browser. Today, you are finally going to see how
JavaScript comes alive within the br owser and how you integrate it with HTML an d
CSS. Because that part o f JavaScript is designed to run exclusively on the side of a
client—a computer th at runs the web browser—you’ll often hear the term client-side
JavaScrip t conne cted with it.
The very basic object of client-side Java Script is the Window object, which repr esents
a web browser’s window and takes the role of the client-side JavaScript global object.
You can refe r to the Window object using the window identifier, although you rarely
need to do that explicitly. Because the Window obje ct is in fact the global object,
all its properties and methods are eventually treated as global variables and functions,
and that is actually all you need to know for now. For example, if you want your web
browser to load a page from another URL, you simply assign the URL to the global
location variable:
location = "http://www.checkthisout.com"
Or, if you want to display a message to the v isitor inside a dialog box, you use the
global alert() function:
alert("Let’s rock and roll!");
You can do that because both location and alert() are members of the Window
object. You can find a short selection of other prope rties and methods that the Window
object defines in th e reference on page 427. All in all, you can do lots of things with
window, but I’ll let you discover them on your own.
12.2. Deeper in to the Browser 229
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.204.201