|
-
Jan 12th, 2005, 04:09 AM
#1
Save IFRAME contents [Resolved]
I have an IFRAME on my page like this:
Code:
<iframe width="642" id="idContent" height="350"></iframe>
Underneath that, I have a submit button.
The user can paste anything into this IFRAME which will most likely be in HTML format. I would like to know how I can access what has been pasted into the IFRAME when submitting, so that I can save it to a database.
I don't know how to access the contents though, I've tried this:
Code:
Response.Write(Request("idContent"))
But that doesn't work.
Something tells me that the mechanism behind IFRAMEs is somewhat different. Any pointers would be appreciated.
Last edited by mendhak; Jan 12th, 2005 at 05:15 AM.
-
Jan 12th, 2005, 05:13 AM
#2
Re: IFRAME contents
Got it:
PHP Code:
function cleanHtml() {
var fonts = idContent.document.body.all.tags("FONT");
var curr;
for (var i = fonts.length - 1; i >= 0; i--) {
curr = fonts[i];
if (curr.style.backgroundColor == "#ffffff") curr.outerHTML = curr.innerHTML;
}
}
function setMode(newMode) {
bTextMode = newMode;
var cont;
if (bTextMode) {
cleanHtml();
cleanHtml();
cont=idContent.document.body.innerHTML;
idContent.document.body.innerText=cont;
} else {
cont=idContent.document.body.innerText;
idContent.document.body.innerHTML=cont;
}
idContent.focus();
}
function HTMLEncode(t) {
var t = t.toString().replace(/&/g, "&").replace(/"/g, """);
return(t.replace(/</g, "<").replace(/>/g, ">"));
}
function savedocument() {
setMode(1); //switch doc to html mode for save
// document.xyz.hiddenfield1.value=idContent.document.body.innerText;
//HTMLEncode
document.xyz.hiddenfield1.value=HTMLEncode(idContent.document.body.innerText);
setMode(0); //switch doc back to text mode
document.xyz.submit(); // submit form for save
}
To use it... call savedocument() from the button in the form.
Now to more pressing matters...
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
|
Click Here to Expand Forum to Full Width
|