* You are viewing the archive for July, 2007

Cars are Awesome

When I say cars are awesome, I mean they are awesome in the same way as waking up in a bathtub of ice, suspiciously missing a kidney. Don’t get me wrong, I love getting around fast and on my own. If I didn’t have my car I would probably stumble on my way to find proper transportation to and from work. I just wish there was a “just as good” replacement for our gas guzzling prizes of joy.

The main reason for my hate of the automobile, is the sheer number of moving parts and possible failure points. As you … Continue Reading

Executing JavaScript Cross Window/Iframe (XWS / XSS)

Cross window scripting is one of those most useful techniques when using multiple windows to display different parts of the same site. It allows information between pages to be refreshed and for presentation of data to become synchronized. It is important to know that IFRAMEs are just embedded windows and that given the element node reference of an IFRAME, you can obtain its window context. All JavaScript variables, functions, objects, etc are defined within the window context. To illustrate this point consider the following code:

var myGlobalVariable = “Hello”;

function myFunction()
{
alert( myGlobalVariable );
}

function myFunction2()
{
alert( window.myGlobalVariable );
}

myFunction();
window.myFunction2();
The result of the above … Continue Reading

Properly Cloning Arrays in JavaScript

This one came up during a discussion about Prototype 1.5.1 while looking through its documentation. Basically when you do the following in JavaScript, you are not copying the array, but rather creating another reference to it. In order to properly clone or duplicate an array you have two choices; loop through the array and copying its values or using the concat method. I personally suggest the concat method since its cleaner and keeps the operations withing the native code of your browser.

function cloneArray( originalArray )
{
return originalArray.concat();
}
As always there is a pre-extended version of this functionality in the Array … Continue Reading