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 03:04 AM .
Another thing, if I put alert("here") or anything with alert, then Internet explorer does succeed in changing the value of the textarea.
Originally Posted by
rpcarnell
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?
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!
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.
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
Forum Rules
Bookmarks