Browser Events
Browser Object Model
Window Object
- Acts as
Global
object. - Variables added to global scope via
var
have their[[Configurable]]
attribute set tofalse
and cannot be removed viadelete
. - If
foo
is not defined, trying to accessfoo
will throw aReference Error: foo is not defined
whilewindow.foo
will return undefined (because it is a property lookup). - Each frame has its own
window
object.top
ferences the outermost frame,parent
points to the current frame's immediate parent frame. window.screenLeft
,window.screenX
,window.screenTop
,window.screenY
window.innerWidth
,window.innerHeight
,window.outerWidth
,window.outerHeight
window.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.location
to 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
|
$('#...') |
|
|
|
|
|
|
|