Welcome to WebmasterWorld Guest from 54.144.107.83

Forum Moderators: open

Message Too Old, No Replies

Viewing the HTML that a javascript produces

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

Junior Member

10+ Year Member

joined:Jan 14, 2002
posts:118
votes: 0


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)

Senior Member

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

joined:May 26, 2000
posts:37301
votes: 0


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

Junior Member

10+ Year Member

joined:Jan 14, 2002
posts:118
votes: 0


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)

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


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)

Junior Member

10+ Year Member

joined:Jan 14, 2002
posts:118
votes: 0


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

Allen

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

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


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)

Junior Member

10+ Year Member

joined:Jan 14, 2002
posts:118
votes: 0


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)

Full Member

10+ Year Member

joined:Jan 31, 2002
posts:285
votes: 0


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)

Junior Member

10+ Year Member

joined:Dec 6, 2002
posts:191
votes: 0


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

GeorgeGG

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

Junior Member

10+ Year Member

joined:Jan 14, 2002
posts:118
votes: 0


Cool. Thanks.

That'll save me time in the future :)

Allen