www.webdeveloper.com
Results 1 to 3 of 3

Thread: Dynamically writing an iframe

  1. #1
    Join Date
    Oct 2005
    Posts
    37

    Dynamically writing an iframe

    Hello there. I'm having problems writing a "preview window" for some user input. Essentially, I have a <textarea> that I'm pulling their input from, and replacing the contents of an iframe with that data.

    The problem?
    Instead of writing it as "<div>", etc... it writes "&lt;div&gt;" The browser therefore just displays all the text instead of interpreting it as html.

    Code:
    function content() {
       return(document.getElementById('content_area').innerHTML);
    }
    	
    function preview() {
    	
       contents = content();
    	
       window.frames.preview_pane.document.open();
       window.frames.preview_pane.document.write("<html><body>");
       window.frames.preview_pane.document.write(contents);
       window.frames.preview_pane.document.write("</body></html>");
       window.frames.preview_pane.document.close();
    
    }

  2. #2
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,114
    I've done it in PHP by escaping the characters instead of using the HTML equivalents.

  3. #3
    Join Date
    Oct 2005
    Posts
    37
    I actually just figured it out! You have to use the following:

    document.getElementById('content_area').value

    ...instead of innerHTML! Otherwise it replaces the actual < > values with the place-holders.

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