Three ways to define a JavaScript class

April 3, 2010

Introduction JavaScript is a very flexible object-oriented language when it comes to syntax. In this article you can find three ways of defining and instantiating an object. Even if you have already picked your favorite way of doing it, it helps to know some alternatives in order to read other people’s code. It’s important to note that there are no classes in JavaScript. Functions can be used to somewhat simulate classes, but in general JavaScript is a class-less language. Everything is an object. And when it... [Read the full story]

Finding Window Dimensions with Javascript

December 13, 2008

Sometimes you may want to find the dimensions of the user’s browser window. Below is a list of the propertiesthat are accessible with different browsers. Traditionally, window.innerWidth/window.innerHeight is the most widely accepted way to obtain these values, however, there is deviation between IE 4 and IE 6+ in “standards compliant mode.” Below, I have listed the different ways to find the window height and width. Non-IE Browsers window.innerWidth window.innerHeight IE 6+ in “standards compliant mode” document.documentElement.clientWidth document.docuementElement.clientHeight IE... [Read the full story]