javascript - get the content as well tags of the editable area from iframe editable -


i have created small editor have done few commands example font formatting and
alignment etc working fine in browsers want export data written
in editable area while tried fetch data inside editable iframe gives me error.
error message: uncaught referenceerror: innerdoc not defined
the following code written

<html><head><title></title>
<script>
function iframeon() {
richtextfield.document.designmode = 'on';
}
function export_data() {
var n = document.getelementbyid("richtextfield");
var innerdoc = n.contentdocument || n.contentwindow.document;
var input = innerdoc.getelementsbytagname('body').text;
var zip = new jszip();
zip.add("hello1.html", ""+input);
zip.add("hello2.js", "this simple file");
content = zip.generate();
location.href="data:application/zip;base64," + content;
</script> </head>
<body>
<iframe name="richtextfield" id="richtextfield" class="form-control" style="height:100%; word-wrap:break-word;">
<button onclick="export_data()" name="export">export information</button>
</body>
</html>



please me out problem

if on same domain, try this. won't let access iframe contents if iframe of different origin window viewing.

var n = document.getelementbyid("richtextfield"); var innerdoc  = n.contentdocument.body.innerhtml; 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -