Wednesday, April 19, 2006

Firefox View Source Trick

I might be the last one on the planet to discover this one, but I doubt it, so I thought I'd share.

I'm used to right-clicking on a page and selecting "View Page Source" from the context menu. This has some advantages over the same command in the View menu because it allows you to narrow down which frame you want to view.

Last night, however, I accidentally selected some text and right clicked. I noticed that the familiar "View Page Source" menu item had changed to a "View Selection Source". It seems that if an straight-forward subset of the document is spanned by the selection, the resulting view source window will only display that portion. If, however, the selection spans disjoint elements in the tree, the whole document will be displayed with the relevant pieces hilighted.

This in and of itself is really helpful for comprehending a complex HTML structure, but there is one more thing I noticed that is even better:

The output of the View Selection Source command seems to be the HTML representation of the current structure of the document as opposed to the raw text obtained at page load time. Put another way, the changes made via JavaScript to the HTML DOM are displayed by View Selection Source.

I know there is an extension that lets you view the live document structure but I've never installed it and this is an easy trick that seemingly produces the same result.

1 Comments:

Blogger academic said...

Interesting blog. It would be great if you can provide more details about it. Thanks you.
Truck Chrome stacks

10:19 PM  

Post a Comment

<< Home