September 2007

Differences of function.apply() and function.call() in JavaScript

Function object methods function.apply() and function.call() basically do the same job, that is to invoke the function as if it was the method of a specified object so that the ‘this’ keyword within the function is treated as that object rather than the global object. var x = 20; function f(s) { alert(this.x + s); …

Differences of function.apply() and function.call() in JavaScript Read More »

DOM event detection: event bubbling and event capturing

There’s essentially 2 ways for the DOM to detect any events, namely event capturing and event bubbling. Event capturing is a method that the browser captures the event from the top elements to the bottom where the event actually takes place. For example, the moment you click on an <img> which is the child of …

DOM event detection: event bubbling and event capturing Read More »

Make elements translucent & semi-transparent with CSS – the bulletproof solution to CSS transparency

Take a div of class translucent for example, you can literally make it translucent with the following CSS rules. It’s bulletproof, meaning that all the browsers will render it as you have specified. Enjoy! div.translucent { /* this class makes a window partially transparent */ opacity: .5; /* Standard style for transparency */ -moz-opacity: .5; …

Make elements translucent & semi-transparent with CSS – the bulletproof solution to CSS transparency Read More »

JavaScript: Changing Browser Window Width / Height

This petite JavaScript snippet defines several functions in the namespace of Geometry that will come handy when you need to manipulate window geometry, freeing you from the depressing chores of distinguishing different browsers for their distinct implementations of virtually the same features. /** * This module defines functions for querying window and document geometry. * …

JavaScript: Changing Browser Window Width / Height Read More »

Scroll to Top