dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: Passing from Iframe to a textbox

  1. #1
    Join Date
    Feb 2005
    Location
    Florida
    Posts
    219

    Passing from Iframe to a textbox

    The following script is supposed to pass the data inside an IFrame called myFrame to a textbox called p_message when I make changes to the IFrame, which has designmode set to on.

    It works in Firefox, but it is not working on Internet Explorer. I write stuff on the Iframe called myFrame, but it does not appear on the textbox when the function Show() is called.

    Can anyone help?

    function Show()
    {
    oRTE = document.getElementById("myFrame").contentWindow.document;


    if (document.all)
    {
    document.getElementById("p_message").value = oRTE.body.innerHTML;
    }
    else {
    document.getElementById("p_message").value = document.getElementById("myFrame").contentWindow.document.body.innerHTML;
    }
    setTimeout("Show()", 2000);
    }
    Last edited by rpcarnell; 11-30-2008 at 04:04 AM.

  2. #2
    Join Date
    Feb 2005
    Location
    Florida
    Posts
    219
    Another thing, if I put alert("here") or anything with alert, then Internet explorer does succeed in changing the value of the textarea.

  3. #3
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Quote Originally Posted by rpcarnell View Post
    Another thing, if I put alert("here") or anything with alert, then Internet explorer does succeed in changing the value of the textarea.
    First document.all is not unique to I.E., although both those branches appear the same.

    When are you calling this function relative to the loading of the iframe?

    Do you control the content of the iframe's document?

  4. #4
    Join Date
    Feb 2005
    Location
    Florida
    Posts
    219
    The Iframe already has text inside when it is called by Function Show().

    And yes, you are right, inside document.all, there was a mistake, which I fixed.
    It should be like this:

    if (document.all)
    {
    oRTE = frames["myFrame"].document;
    oRTE.addEventListener("keypress", thisfuncnow, true);
    document.getElementById("p_message").value = oRTE.body.innerHTML;

    }

    That's how it works for IE, only if I put alert("here") inside document.all. I tested the script with Opera, Firefox, and Safari, and there are no problems there.

  5. #5
    Join Date
    Feb 2005
    Location
    Florida
    Posts
    219
    One theory I have is that IE only gets the value inside the Iframe when you have this code:

    oRTE.open();
    oRTE.write(pureblog);
    output = oRTE.body.innerHTML;/*there's innerhtml after pureblog has been written into the frame*/
    oRTE.close();

    then output will have what I need. What's the catch? I can't just type oRTE.open(), I may end up erasing everything inside the Iframe.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles