javascript - copy contenteditable HTML to iframe -


i'm making html reader inside html (for reasons...)

i used able fine. took value of text area , applied iframe, this:

    var x = document.getelementbyid("htmldocument");     var y = (x.contentwindow || x.contentdocument);     if (y.document)y = y.document;     y.body.innerhtml = document.getelementbyid('page').value; 

but there style (the textarea did not background-attachment:local; property) had change div contenteditable , here new code:

    var x = document.getelementbyid("htmldocument");     var y = (x.contentwindow || x.contentdocument);     if (y.document)y = y.document;     y.body.innerhtml = document.getelementbyid('page').textcontent; 

but basic html copies on iframe... how fix this? no html copies on if use .innerhtml instead of .textcontent. it's annoying. 1 thing wrong...

native javascript (for reasons , purposes)

jsbin demo

use innerhtml whole inner html string:

document.getelementbyid('page').innerhtml; 

that take complete paragraph out of elementwith al lthe related styles:

<div id="page" contenteditable>     <p style="color:red">foo</p> </div> 

var x = document.getelementbyid("htmldocument"); var y = (x.contentdocument || x.contentwindow); if (y.document) y = y.document;  // might work in chrome fail in firefox // y.body.innerhtml = document.getelementbyid('page').innerhtml;  // rather: y.open(); y.write( document.getelementbyid('page').innerhtml ); y.close(); 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -