• Home
  • Flailing Wildly
  • Résumé
  • Design
  • Code
  • Wishlist
  • About Me

Flailing Wildly
Too much straw, not enough camel.

Awesome view-source trick for JavaScript developers

by Ryan Parman • February 14, 2006 • Browsers, Code • 4 comments

Maybe I’m a little slow, but I’ve found an awesome little trick for people who use Firefox, and who need to dynamically add elements to the page via JavaScript.

I’ve been doing a lot of Ajax development lately for an internal webapp where I need to dynamically add nodes to lists. In my source code, I’ll have an empty <ul> tag with an ID, then I use that ID when I go and add <li>‘s to it. No big deal, right?

If you use the standard view-source contextual menu item, it will show you the source code that you coded in: the empty <ul> tag. BUT, if after you’ve added your <li> nodes dynamically, you click-and-drag to select the rendered area, and choose “View Selection Source”, Firefox will show you the fully-rendered HTML for that area. As in, it will show you the <ul> tag with all of your <li> tags inside of it… just as though you’d coded it like that in the first place. How awesome is that?

So if you need to see what HTML your JavaScript is generating, simply select the area, and choose “View Selection Source”.

Ryan Parman

Ryan Parman is an entrepreneur, open source evangelist and passionate usability advocate currently living in Seattle. He is the founder and visionary behind SimplePie and CloudFusion, co-founder of WarpShare, member of the RSS Advisory Board, and is currently with Amazon. Ryan's aptly-named blog, Flailing Wildly, is where he writes about ideas longer than 140 characters.

« Okay, some people are seriously retarded
YouTube: Travis Barker – Snare Drum Solo »

Discussion

Andrew K.

February 14, 2006

oh my, how on Earth did you develop ajax apps without knowing about this and NOT go completely insane?? ;D

Make sure you also check out Firebug, which is easily the best FF extension for JS developers.

If that seems overkill to you, you might like Console2, which fixes the small problems with the Error Console that make it painful to use (eg: “I don’t care about CSS or chrome errors right now, I’m just trying to fix this damn script!!” )

Ryan Parman

February 14, 2006

I’ve always relied on my memory to understand how it all comes together. :) I’m also a huge Firebug fan. I’ve used it nearly every single day of my life since it was released!

Geoffrey Sneddon

February 15, 2006

Andrew, did you not realise Ryan is insane? :D

Doug

March 6, 2006

This is a good tip. If you need to see the generated source for the whole page, just type Ctrl-A, then View Selection Source

Comments for this post are now closed.

Blog search

Archives
  • 2010 (7)
  • 2009 (7)
  • 2008 (12)
  • 2007 (8)
  • 2006 (18)
  • 2005 (57)
  • 2004 (104)
  • 2003 (103)
Categories
  • Apple (43)
  • Browsers (55)
  • Code (57)
  • Creating Websites (31)
  • Design (5)
  • Digital Media (3)
  • Family Life (10)
  • Just for Fun (25)
  • Music (5)
  • Personal (32)
  • Political (12)
  • Projects (44)
  • Software (60)
  • Syndication (28)
  • Technology (75)
  • Tutorials (5)
  • TV and Movies (16)
  • Video Games (5)
  • Website (62)
  • Work and Business (3)
  • Writing (4)
Socially-aware
  • Twitter
  • Facebook
  • Flickr
  • Last.fm
  • Glue
  • YouTube
  • Delicious
  • LinkedIn
Claim to fame
  • Amazon Web Services
  • WarpShare
  • CloudFusion
  • SimplePie
Legal mumbo-jumbo

All ideas, opinions and comments I post are my own and are in no way affiliated with anybody I work with. If you quote and/or reprint something I've written or said, please direct folks back to this site as a form of attribution. I promise I'll do the same for you. Unless otherwise noted, all content on this site is copyright © 1979–2010 Ryan Parman. Powered by Rocket Sauce.