homepage Welcome to WebmasterWorld Guest from 54.145.183.190
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Viewing the HTML that a javascript produces
Allen

10+ Year Member



 
Msg#: 302 posted 10:45 am on Mar 10, 2003 (gmt 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

 

tedster

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



 
Msg#: 302 posted 11:41 am on Mar 10, 2003 (gmt 0)

View Source in Netscape 4 might do it for you.

Allen

10+ Year Member



 
Msg#: 302 posted 2:02 pm on Mar 10, 2003 (gmt 0)

Hmmmm,

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

Thanks,

Allen

jdMorgan

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



 
Msg#: 302 posted 2:22 pm on Mar 10, 2003 (gmt 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

Allen

10+ Year Member



 
Msg#: 302 posted 2:56 pm on Mar 10, 2003 (gmt 0)

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

Allen

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 302 posted 11:41 pm on Mar 10, 2003 (gmt 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.

Allen

10+ Year Member



 
Msg#: 302 posted 12:30 pm on Mar 11, 2003 (gmt 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

10+ Year Member



 
Msg#: 302 posted 3:19 pm on Mar 11, 2003 (gmt 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.

GeorgeGG

10+ Year Member



 
Msg#: 302 posted 12:11 am on Mar 12, 2003 (gmt 0)

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

GeorgeGG

Allen

10+ Year Member



 
Msg#: 302 posted 8:47 am on Mar 12, 2003 (gmt 0)

Cool. Thanks.

That'll save me time in the future :)

Allen

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved