Aug. 15, 2008 at 11:24amWindow.Name experiment

Does anyone use it yet?

I am starting an experiment to see whether the recent blog chatter about window.name is actually being used. Included is some JavaScript that you can put in GreaseMonkey to help me in my search.First, a quick intro to window.name. It is a javascript variable within a web browser that is intended to allow frames or popups communicate with each other. Because frames are free to do as they like, the communication between a particular set of frames could broken if just one frame resets its variables (like refreshing the frame). So window.name must remain between page refreshes to make sure communication isn't broken.

There has been a lot of talk lately about storing scripts or session-like variables within window.name, giving you the flexibility of having a session state without messing around with cookies. But I have yet to see a site that uses this functionality. So I decided to start a little experiment.

Using GreaseMonkey, I created a real quick script (below) to alert me if there is something in the window.name variable. It also checks to make sure there are no frames on the page, because I found that throws up a lot of alert boxes. So I'll keep this script running on my browser while looking at new web apps and see if anything interesting comes up. If anyone else would like to try it, let me know and I'll help set you up.

switch(window.name) {
default: alert(window.name);
// Garbage window.names below this line
case undefined:
case '':
case 'google_ads_frame':
}

UPDATE (08/18/2008):
I found that frames were giving false positives. This is particularly annoying when working with an rich text editor in the browser. So I updated the code below.

// Removes Frames
if(window.name !== window.parent.name) return

switch(window.name) {
default: alert(window.name);
// Garbage window.names below
case undefined:
case '':
}

UPDATE 2 (08/28/2008)
So far, the only site I have seen using the window.name property is AppleInsider.Com, which I believe they are using for communication between their popup ads and the main site. It's rather interesting to an alertbox after every page refresh after an AppleInsider page loads.

Add your comment below

Leave a Comment

Remember me

Name:

Email:

URL:

Comment: * No HTML, http:// will auto-link
* required
Comment Guidelines