Results 1 to 2 of 2

Thread: Save IFRAME contents [Resolved]

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  2. #2

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: IFRAME contents

    Got it:

    PHP Code:


    function cleanHtml() {
      var 
    fonts idContent.document.body.all.tags("FONT");
      var 
    curr;
      for (var 
    fonts.length 1>= 0i--) {
        
    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.toString().replace(/&/g"&amp;").replace(/"/g, "&quot;");
      return(t.replace(/</g, "
    &lt;").replace(/>/g, "&gt;"));
    }


    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
  •  



Click Here to Expand Forum to Full Width