View Full Version : Getting source for a javascript-written page...
doggo18
04-28-2003, 12:20 PM
Hiding source (http://www.vortex-webdesign.com/help/hidesource.htm)
At this link I found a script to see the source of a written page..
I was wondering if anyone has written a script to get the contents of a javascript-written (document.writeln) frame.
One of my frames is being written using javascript, and there is a mistake somewhere causing my layout to mess up, but I can't find it in my javascript code because its large :rolleyes:
Thanks :)
x_goose_x
04-28-2003, 12:31 PM
How bout directing the write to a textarea?
change:
document.write(PageHTML);
to:
document.write("<textarea cols=100 rows=20>"+PageHTML+"</textarea>");
OR:
document.FormName.ElementName.value = PageHTML;
Roy Sinclair
04-28-2003, 04:48 PM
Look at the bookmarklet (http://www.codingforums.com/showthread.php?s=&threadid=4500&highlight=bookmarklet) thread here for a url you can set up as a bookmark in NS6 or modify the URL for a IE Favorite to contain. It'll show you the resulting html no matter how diligently they try to hide it.
brothercake
04-28-2003, 05:06 PM
Or did you mean the actual HTML code generated by the javascript - the output code?
In which case, I'd recommend you download the mozilla (if you don't have it already) and check out its DOM inspector
beetle
04-28-2003, 05:16 PM
javascript:var h = document.documentElement.outerHTML; var nTitle = unescape(window.location.href); h=h.replace(/</g, '<'); var srcWin; srcWin = window.open('','srcWin',''); with (srcWin.document) { writeln('<html><head><title>Source Code for '+nTitle+'</title></head><body>'); writeln('<pre>'); writeln(h); writeln('</pre>'); writeln('</body></html>'); close(); }
doggo18
04-28-2003, 08:07 PM
Javascript not being my strongest point, I am glad I figured it out after all :) I was looking for the output Javascript made (no source hiding stuff in this case :p), but the problem was the output went straight inside a frame. Using "View source" made me end up starting at the 'placeholding' document that would be overwritten by the script. And none of the scripts I could find would look into a frame..
Using the Reveal Generated Source link from above, this is what I messed together... I know it might be crappy and all, but it works for me :)
javascript:(function(){%20function%20htmlEscape(s){s=s.replace(/&/g,'&');s=s.replace(/>/g,'>');s=s.replace(/</g,'<');return%20s;}%20var%20myframe=prompt("What frame do you wish to see?","Frame here");%20x=window.open();%20x.document.write('<pre>'%20+%20htmlEscape('<html>\n'%20+%20top.frames[myframe].document.documentElement.innerHTML%20+%20'\n</html>'));%20x.document.close();%20})();
The original code was:
javascript:(function(){%20function%20htmlEscape(s){s=s.replace(/&/g,'&');s=s.replace(/>/g,'>');s=s.replace(/</g,'<');return%20s;}%20x=window.open();%20x.document.write('<pre>'%20+%20htmlEscape('<html>\n'%20+%20document.documentElement.innerHTML%20+%20'\n</html>'));%20x.document.close();%20})();
I hope someone else might be able to use it :) Thanks for the help everyone :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.