/    Sign up×
Community /Pin to ProfileBookmark

Viewing source when dynamically creating a document

Hi,

I am dynamically creating a document using things such as

var div = document.create(“div”);
div.appendChild();

etc etc …

It works great but what is the best way to view the source of the dynamically created object, or what is the best way to debug the dynamically created HTML in the case of an error which I can’t see in the script.

Thanks in advance,

AusChucky

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@NXInteractifMar 04.2009 — Do you have a link to your demo/tester page so that I may see exactly what the context of your problem is?
Copy linkTweet thisAlerts:
@FangMar 04.2009 — Use the Web Accessibility Toolbar for IE and Web Developer for Fx, both have a 'view generated source'
Copy linkTweet thisAlerts:
@Declan1991Mar 04.2009 — [url=getfirebug.com]Firebug[/url] will also show the generated source.
Copy linkTweet thisAlerts:
@MigMar 04.2009 — I use Firebug too. When you inspect the DOM, it shows the generated source.
Copy linkTweet thisAlerts:
@MrRedMar 04.2009 — my methodology is to document.write from one function only (called dw()) and have a variable to switch the writing. when dumping it changes > & < to safe characters, and along with a few others like "&". then I run, select and copy results to a text editor and bulk re-instate the correct characters. copy and paste to an HTML blank.

for two reasons.

1) I get to see exactly what it looks like so can edit in html before going to correct the JavaScript. colours and positions can be played with more easily in an HTML editor.

2) on my homepage the same data is in HTML to cover the JavaScriptophobes who will or can NOT run the code.

http://cresby.com or (= http://www.users.waitrose.com/~cresby/index.htm)
Copy linkTweet thisAlerts:
@MrRedMar 04.2009 — Perhaps I should re-visit Firebug.
Copy linkTweet thisAlerts:
@AusChuckyauthorMar 04.2009 — Thanks for all your replies.

I'm a big fan of firebug so i'll give that a shot. Also I found that alert(div.innerHTML); works

Cheers!
Copy linkTweet thisAlerts:
@rnd_meMar 04.2009 — in firefox:

click any empty background area of page

<CRTL>+<A>, right-click>View Selection Source

works "on the road", when you don't have firebug...
×

Success!

Help @AusChucky spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...