Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > get contents of iframe

Reply
Thread Tools

get contents of iframe

 
 
markww
Guest
Posts: n/a
 
      04-21-2006
I cannot get the contents of an iframe in my page, it is quickly
driving me insane. My iframe is defined like:

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

I've made a function to retrieve the contents like:

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

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

but it fails. I need this to work on IE and FF, any suggestions?

Thanks

 
Reply With Quote
 
 
 
 
Neredbojias
Guest
Posts: n/a
 
      04-21-2006
To further the education of mankind, "markww" <(E-Mail Removed)>
vouchsafed:

> I cannot get the contents of an iframe in my page, it is quickly
> driving me insane. My iframe is defined like:
>
> <iframe id = "e_body" name = "e_body" src="about:blank"></iframe>
>
> I've made a function to retrieve the contents like:
>
> function GetIFrameContentsPlease()
> {
> var strContents =
> document.getElementById("e_body").document.body.in nerHTML;
>
> alert("the contents are: " + strContents);
> }
>
> but it fails. I need this to work on IE and FF, any suggestions?


You realize you do need an actual source (-html document) in order to get
the contents of the iframe? I don't know if "about:blank" does it.

With that in mind, try this:

setTimeout("alert(e_body.document.body.innerHTML); ",10);

--
Neredbojias
Infinity has its limits.
 
Reply With Quote
 
 
 
 
markww
Guest
Posts: n/a
 
      04-21-2006
Hi,

Yes there is no initial content, but the user is allowed to type in the
iframe with designMode = 'on' - I just need to get whatever they have
typed into the iframe. I'll give what you posted a try,

Thanks

 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      04-21-2006
markww wrote:
> Hi,
>
> Yes there is no initial content, but the user is allowed to type in the
> iframe with designMode = 'on' - I just need to get whatever they have
> typed into the iframe. I'll give what you posted a try,
>
> Thanks
>

If I understand you correctly you are using an IFRAME to get user input?
HTML already contains an element for such purpose, it is a FORM with a
TEXTAREA. Why the re-engineering?

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
markww
Guest
Posts: n/a
 
      04-21-2006
Hi Jonathan,

I wanted to use an iframe so that the user could do some limited rich
text formatting, and I wouldn't have to script anything extra. I would
like there to be a button beneath the iframe such as 'edit' - in which
case the user can start typing in there, make text bold, type weblinks
like www.something.com. Then they could just hit 'stop edit', in which
case I'd just turn design mode 'off' and the weblinks they typed become
active, the rich text maintains its formatting, etc.

All I'd have to do is flip the designMode switch.

Textareas as I understand don't allow for such formatting or clickable
links?

Thanks

Jonathan N. Little wrote:
> markww wrote:
> > Hi,
> >
> > Yes there is no initial content, but the user is allowed to type in the
> > iframe with designMode = 'on' - I just need to get whatever they have
> > typed into the iframe. I'll give what you posted a try,
> >
> > Thanks
> >

> If I understand you correctly you are using an IFRAME to get user input?
> HTML already contains an element for such purpose, it is a FORM with a
> TEXTAREA. Why the re-engineering?
>
> --
> Take care,
>
> Jonathan
> -------------------
> LITTLE WORKS STUDIO
> http://www.LittleWorksStudio.com


 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      04-21-2006
markww wrote:
> Hi Jonathan,
>
> I wanted to use an iframe so that the user could do some limited rich
> text formatting, and I wouldn't have to script anything extra. I would
> like there to be a button beneath the iframe such as 'edit' - in which
> case the user can start typing in there, make text bold, type weblinks
> like www.something.com. Then they could just hit 'stop edit', in which
> case I'd just turn design mode 'off' and the weblinks they typed become
> active, the rich text maintains its formatting, etc.


Many rich text widgets out there, here is one:

http://dojotoolkit.org/docs/rich_text.html
Rich Text Editing With Dojo
--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding contents on yaml file without overwriting actual contents Kamarulnizam Rahim Ruby 4 01-28-2011 09:10 AM
Get parent iframe element in iframe Cleaner1912@gmail.com Javascript 0 09-27-2006 05:16 AM
Need to get offsetLeft of an iframe or div inside another iframe Nathan Carr Javascript 0 09-17-2004 01:27 PM
Can I restrict both attribute contents and element contents in schema Don Adams XML 1 03-05-2004 12:48 PM
Get form values from iframe (1) to iframe (2) inside a layer in iframe (1) Daedalous Javascript 3 01-16-2004 11:08 AM



Advertisments