?
Solved

Get contents of iframe

Posted on 2006-04-20
4
Medium Priority
?
263 Views
Last Modified: 2010-04-09
Hi,

I just want to get the contents of an iframe on my page. My iframe is defined like:

    <iframe id = "e_body" name = "e_body" src="about:blank"></iframe>

Now I have a function where I want to get the inner contents of the frame, whatever the user has typed in there:

function GetIFrameContentsPlease()
{
    var strContents = document.getElementById("e_body").document.body.innerHTML;

    alert("the contents are: " + strContents);
}

But getting the content always fails, how can I get it?
0
Comment
Question by:minnirok
  • 2
4 Comments
 
LVL 7

Expert Comment

by:bubbledragon
ID: 16504686
document.frames("e_body").document.body.innerHTML;
0
 
LVL 7

Accepted Solution

by:
bubbledragon earned 2000 total points
ID: 16504719
getElementById method:

document.getElementById('e_body').contentWindow.document.body.innerHTML;
0
 
LVL 8

Expert Comment

by:KennyTM
ID: 16504862
Because of security concerns, you cannot get the innerHTML cross domain (without appropriate priviledges).
0
 
LVL 7

Author Comment

by:minnirok
ID: 16511578
yes finally it works!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question