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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the HTML in an IFRAME

Status
Not open for further replies.

BenRussell

Programmer
Mar 12, 2001
243
0
0
US
I have an IFRAME in my website.

I want to be able to capture the HTML in the IFRAME (that points to another page on my websiet) when a form is submitted. How can I do this?

- Ben
 
Need a little more info. Do you need to capture the info to a database or send it via email?

Is it details in a form?

Reality is built on a foundation of dreams.
 
Not exactly sure what you're after but something like this should be possible in javascript:

var vHTML = $iframename.document.location.innerHTML;

This will pull all the inner html into a variable for you to post in a form (ie4+). However its not always as simple as that - netscape will doubtless work differently...

Explain in more depth what it is you want to do.

Joe
 
I used the javascript code above:

var vHTML = $iframename.document.location.innerHTML;

But it does not capture the HTML inside the <head> tag and it does not include the document's closing tags (</html>).

- Ben
 
var vOHTML = $iframename.document.location.outerHTML;

try this...

or you can append them yourself (dependant on how static the info is...

var vHTML = &quot;<HTML><HEAD>head stuff here</HEAD>&quot; + $iframename.document.location.innerHTML + &quot;</HTML>&quot;;

it all depends on what you're trying to do
 
window.frameName.document.documentElement.outerHTML

only works for pages in the same domain. If iframe contents is pointing to another site the above code will show an access denied message
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top