Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving HTML code from another window 1

Status
Not open for further replies.

robherc

Programmer
Apr 20, 1999
921
US
Hello;

I'm working on a site w/3 frames ([tt]master[/tt], [tt]demoframe[/tt], and [tt]sourceframe[/tt]). When a user clicks on a link in the navbar ([tt]master[/tt]) an html file is opened in [tt]demoframe[/tt]. What I need to do now, is create a function I can call from either [tt]master[/tt] or [tt]sourceframe[/tt] to read the html code from the page I just opened in [tt]demoframe[/tt] into a string (parsing it from there is not the issue, just need to retrieve the html code).
Bandwidth on my server is very much at a premiur right now, so I'm really wanting to do this without generating another request for the .html file from my server (i.e. all handling and manipulation must be client-side). Any ideas?
Is there a DOM object I can read a page's sourcecode out of?


Thanks in advance for any help you can provide;
Rob Hercules
 
assuming you know how to access the frame, call this and it should give you the output of the page:

Code:
var str = document.getElementsByTagName("html")[0].innerHTML;
alert(str);

This should return all the code for the page (minus the <html> tags). If you want to see the <html> tags then you can use outerHTML, but that is IE only I believe.

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Thank you very much, that's exactly the DOM object I needed...

*Gets back to work ironing bugs*


Thanks;
Rob Hercules
 
[purple]you're welcome[/purple]

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
[purple]very[/purple]

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top