views:

54

answers:

4

Is there a way to show html source in the browser after insertion by js via ~.innerHTML = Source; ?

+4  A: 

If you're working with Firebug/Firefox or with IE8, the DOM viewer can show you the "live" DOM. It's not really "source", but I'm pretty sure that's what you're asking about.

(I didn't mention Safari or Chrome because I don't do much development with those, but they probably have similar facilities. I'm just not personally familiar.)

Pointy
Drive-by downvotes are so pleasant.
Pointy
Safari and Chrome has a built-in HTML/JS/DOM degubber like IE8, so we could say that it's implemenetd in every major navigator :)
Adirael
A: 

This will show the html sourcecode:

alert('<html>'+document.head.outerHTML+document.body.outerHTML+'</html>');

If you want a pretty way to see it, download a highlighting library.

M28
Might be a little unwieldy. At least the DOM viewer/inspector highlights the code and provides a UI for live modifications for debugging/testing.
Pointy
I thought he wanted the html source code, just implement a library to display the html and you're done :B
M28
this is non-standard and IE-only. see here for a cross browser fix: http://snipplr.com/view/5460/outerhtml-in-firefox/ [EDIT] and here: http://stackoverflow.com/questions/1700870/how-do-i-do-outerhtml-in-firefox
seanizer
By the way, it works in google chrome, so it's not ie-only -___-
M28
A: 

The WebDeveloper add-on for Firefox among its many useful features also has a 'View Generated Source' feature that works just like view source, but includes the dynamic content. Simple and quick.

https://addons.mozilla.org/en-US/firefox/addon/60/

Matthew Smith
A: 

Pure Firefox without any plugins: select code with mouse -> right-click -> "View Selection Source"