Changing the window scope in Firebug
November 15, 2008
Applications | CSS | Firefox | Javascript | Web Building

If I had to choose one piece of advice for new web developers, I'd tell them to learn to use Firebug. Firebug is probably the most valuable debugging tool available, but if you are just getting started, it may seem pretty opaque at first.

In addition, some things do not appear to work as advertised. In particular, the "cd" function does nothing as far as I can tell.

The page that documents the commands you can use within Firebug lists the cd command as a way of changing the window scope:

Picture 23.png


Ads by Google

Posted by ellen at November 15, 2008 01:18 PM

Let's say you want to test for the existence of something (a function, property, etc.) within a page. If you are working with a single window, you would simply type the name of the property into the command line and firebug returns the current value of that property, or "null" or "undefined".

But what if the property you want to examine resides within a window that is inside a frame? You need to change the scope that is being addressed so that your expression is evaluated within the correct frame.

You are supposed to be able to type "cd(frameName)" or "cd(top)" to change the window scope of the succeeding commands. Yet, I've tried just about every possible way of addressing windows and frames with it, and it never seems to work. It always returns "null".

firebugCD.jpg


However there are other ways to get almost the same results.

If you are not certain exactly what you are looking for, you can just type:

values(frameName); into the command line box

and you will get a listing of every value of ALL properties of the object.
values.jpg

And if you simply enter "frames[0]" you will get a navigable DOM listing of everything within that frame similar to the listing in the DOM tab.

Picture 18.jpg

To inspect a specific property of frames[0], type
frames[0].property

Picture 3.jpeg

Picture 5.jpeg

Reblog this post [with Zemanta]

Ads by Google


Ads by Google

 RSS   |   Contact Me


Ads by Google