Browser Events

Browser Object Model
Window Object
- Acts as
Globalobject. - Variables added to global scope via
varhave their[[Configurable]]attribute set tofalseand cannot be removed viadelete. - If
foois not defined, trying to accessfoowill throw aReference Error: foo is not definedwhilewindow.foowill return undefined (because it is a property lookup). - Each frame has its own
windowobject.topferences the outermost frame,parentpoints to the current frame's immediate parent frame. window.screenLeft,window.screenX,window.screenTop,window.screenYwindow.innerWidth,window.innerHeight,window.outerWidth,window.outerHeightwindow.resizeTo(),window.resizeBy()
window.open()can return null if pop-up blocker prevents it from happening.window.close()to close.setTimeout()andsetInterval()are window methods.- Avoid intervals, better to recurseviely call
setTimeout()
- Avoid intervals, better to recurseviely call
Location Object
hash,hostname,href,pathname,search(query string)- Set
window.locationto navigate replace()to navigate to a URL but not update the history stackreload()reloads current page
Navigator Object
TODO * Browser information
Document Object Model
Node Type
All node types inherit from Node in JavaScript. A node n shares the same basic properties:
|
A number from 1 - 12 |
|
For elements, the tag name |
|
For elements, always null |
|
A NodeList, an array like object of child nodes.
Can be accessed via bracket notation, n.childNodes[0]
or the item() method, n.childNodes.item(1)
Also contains a length property.
|
|
Parent in the document tree |
|
|
|
|
|
|
|
|
|
More efficient than n.childNodes.length |
|
Quick way to access Document node rather than traversing up the node hierarchy |
|
Add node to the end of childNodes.
If passing in a node, remove it from previous location. |
|
Accepts two arguments: node to insert and reference node.
null reference node? Act as .appendChild() |
|
|
|
|
|
|
|
Remove empty text nodes and join text nodes that are immediate siblings. |
Document Type
Properties
|
|
|
|
|
|
|
|
|
|
|
|
|
DOMContentLoaded |
|
sub-resources loaded |
Methods
|
|
|
|
|
|
|
|
|
Returns array of 0 or more matched elements
|
|
|
|
Element Type
Properties
|
Number of children |
|
|
|
|
|
|
|
|
|
|
|
|
Methods
|
$('#...') |
|
|
|
|
|
|
|