2009
Sep
21

The z-index property determines the stack level of an HTML element. The stack level refers to the element's position on the Z axis (as opposed to the X axis or Y axis). A higher z-index value means the element will be closer to the top of the stacking order. This stacking order runs perpendicular ot the display, or viewport. In an HTML page, the natural stacking order (i.e. the order of elements on the Z axis) is determined by a number of factors. Below is a list showing the order that iterms fit into a stacking context, starting with the bottom of the stack.

2014
Mar
06

ECMAScript 5's Function.prototype.bind is a great tool that's implemented in all modern browser JavaScript engines. It allows you to modify the context, this, of a function when it is evaluated in the future. Here's a common use case that developers need to watch for. Turns out that since we added the event listener to the window object, this in the event handler or callback refers to window.

2009
Mar
08

A left-floated box will shit to the left until its leftmost margin edge (or border edge if margins are absent) touches either the edge of the containing block, or the edge of another floated box. If the size of the floated box exceeds the available horizontal space, the floated box will be shifted down. Non-positioned, non-floated, block-level elements act as if the floated element is not there, since the floated element is out of document flow.

2009
Apr
26

Netscape maintained that the event on element1 takes place first. This is called event capturing. The event handler of element1 fires first, the event handler of element2 fires last. W3C has very sensibly decided to take a middle position in this struggle. Any event taking place in the W3C event model is first captured until it reaches the target element and then bubbles up again.

2009
Aug
07

Creating an XMLHttpRequest object. Specifying and submitting your HTTP request to a web server. Synchronously or asynchronously retrieving the server's response. The readyState property defines the current state of the XMLHttpRequest object. 0: The request is not initialized. 1: The request has been set up. 2: The request has been sent. 3: The request is in process. 4: The request is completed.

2009
Jun
15

A number that specifies which mouse button changed state during a mousedown, mouseup, or click event. A value of 0 indicates the left button, 1 indicates the middle button, and 2 indicates the right button. Specify the X and Y coordinates of the mouse pointer, relative to the upper-left corner of the browser's viewport and do not take document scrolling into account.

2009
May
26

Cookies are small amounts of data stored by the web browser. They allow you to store particular information about a user and retrieve it every time they visit your pages. Each user has their own unique set of cookies. Cookies are typically used by web servers to perform functions such as tracking your visits to websites, enabling you to log in to sites, and storing your shopping cart.

2009
Apr
20

Here we set up two different event handlers on the newly created script tag. Depending on the browser, one or the other of these two handlers is supposed to be called when the script has finished loading. The onreadystatechange handler works on IE only. The onload handler works on Gecko browsers and Opera.

2014
Mar
05

If the function is able to assign values to its parameters, only its local copy is assigned — that is, anything passed into a function call is unchanged in the caller’s scope when the function returns. Pass-by-reference typically means that the function can modify (i.e. assign to) the variable used as argument — something that will be seen by its caller.

2009
Jun
04

Syntax errors are errors in grammar and punctuation such as mismatched quotes or missed commas. These errors are caught quickly if you have the browser's built-in error detector in display mode or run the script through jsLint. Runtime errors only show up as the script is executed. Common examples are calling a function that hasn't been declared (typing error or case-sensitivity issue) or division by zero. Although JavaScript is typeless, many built in objects expect and/or return specific types (eg. style.left needs string type).

2014
Mar
27

The first digit (a) is always zero, unless there is a inline style attribute applied to that element. The second digit (b) is the sum of the number of IDs in that selector. The third digit (c) is the sum of the number of classes, attributes, and pseudo-classes in that selector. The fourth digit (d) counts the elements and pseudo-elements.