document.images (all images on a page) and
document.links (all links), which were replaced in DOM version 1 with more generic methods such as
BOM stands for Browser Object Model. It’s a nice name for something that’s not formally defined. It’s a collection of browser-related properties and methods, such as available screen size or the status bar. Most of these properties are available as globals such as
innerWidth, although you most often see them used as properties of the
window object (e.g.,
window.innerWidth). BOM hasn’t been standardized for a long time, so as you can imagine, there are some differences across browsers. HTML5 started to codify common behavior among browsers, including the common BOM objects.
It’s also an odd language when you approach it from the perspective of a PHP developer. Here are some things to be aware of early on and look for as you progress through this book:
A console lets you quickly type pieces of code and see them run, just like the interactive PHP shell you invoke on the command line:
In a desktop WebKit browser (e.g., Chrome or Safari), simply load a page, right-click anywhere, and select “Inspect element” from the menu. This brings up the Web Inspector. Click the Console tab and you’re ready to go (Figure 1-2).
In newer Firefox versions, you get to a console by going to the Menu Bar and selecting Tools→Web Developer→Web Console. Alternatively, you can also install the Firebug extension, which works in any Firefox version.
You can make an alias to it so that it’s easier to find:
Type the following:
Feel free to add the
alias line to your
~/.profile so that it’s always there when you need it.