Welcome to WebmasterWorld Guest from 54.146.174.220

Forum Moderators: open

Viewing the HTML that a javascript produces

   
10:45 am on Mar 10, 2003 (gmt 0)

10+ Year Member



Hi all,

I have a rather complex javascript which builds some nice looking menus, but I need to find out the HTML code that the JS uses to do it.
Now I am prepared to go through the entire JS peicing together the HTML bit by bit, but I was wondering if there was a browser or tool that displays what the javascript outputs rather than the javascript itself.

TIA

Allen

11:41 am on Mar 10, 2003 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



View Source in Netscape 4 might do it for you.
2:02 pm on Mar 10, 2003 (gmt 0)

10+ Year Member



Hmmmm,

Just tried 4.8 without any luck. Do you know the specific version?

Thanks,

Allen

2:22 pm on Mar 10, 2003 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Allen,

It's probably just the ambiguous tip: Most versions support it. However, to view URI [example.com,...] type the following into the address bar.

view-source:http://www.example.com

This has worked for me an all 4.x versions.

Jim

2:56 pm on Mar 10, 2003 (gmt 0)

10+ Year Member



Nope. Still displays the javascript ratehr than the code it produces :(

Allen

11:41 pm on Mar 10, 2003 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



It depends exactly what those javascript commands do, how the HTML code is built up. Try running the page through the HTML code validator at [validator.w3.org...] (tick the boxes for show source, and outline as well as parse tree if you are interested) and then on the results page, scroll down past the error list and the outline to where the source code is shown.
12:30 pm on Mar 11, 2003 (gmt 0)

10+ Year Member



I finally got it to do it by changing all the <'s to &lt;'s. The first time I tried it I was in a rush, so wasn't looking at the script properly. Some of the script required some of its output to be there before it would display anything else.

Allen

gph

3:19 pm on Mar 11, 2003 (gmt 0)

10+ Year Member



I see you've found a work around, this might help for next time. If you're using windows you can use JS/activeX to create a file then write the string to it.

str = '<html>...'
Check_Str(str)

function Check_Str(str) {
fso = new ActiveXObject('Scripting.FileSystemObject')
thefile = 'c:\\My Documents\\test.txt'
var TristateFalse = 0
var ForWriting = 2
fso.CreateTextFile(thefile)
a = fso.GetFile(thefile)
b = a.OpenAsTextStream(ForWriting, TristateFalse)
b.Write(str)
b.Close()

alert('function stopped, go check file, come back and click "ok", the file will be deleted')

c = fso.GetFile(thefile)
c.Delete()
}

If you don't want the file deleted you can remove everything after and including the alert.

12:11 am on Mar 12, 2003 (gmt 0)

10+ Year Member



Check:
[worldtimzone.com...]
View Generated Source (IE5,N6,Moz)

GeorgeGG

8:47 am on Mar 12, 2003 (gmt 0)

10+ Year Member



Cool. Thanks.

That'll save me time in the future :)

Allen

 

Featured Threads

Hot Threads This Week

Hot Threads This Month