如何替换html iframe的内容

时间:2013-06-24 11:52:52

标签: jquery html iframe text

您好我想在iframe中执行此命令:

 doc.body.innerHTML = doc.body.textContent;

将文本更改为html,如果在控制台中输入文本,则iframe不合作。 fiddle

HTML:

<div class="iframe">
    <iframe name="ifrm" id="ifrm" scrolling="yes" src='http://www.sec.gov/Archives/edgar/data/1096536/0001047469-03-011504.txt' frameborder="0" width="100%" height="500px" >
        Your browser doesn't support iframes.
    </iframe>
</div>

jquery的:

//alert($('#ifrm').contents()[0].length)
doc = $('#ifrm').contents()[0]

  //show iframe methods
    str = ''
$.each(doc, function(key, element) {
   str = str +('key: ' + key + '\n' + 'value: ' + element);
});
//$('#ifrm').attr('srcdoc',str);

     doc.body.innerHTML = doc.body.textContent;

0 个答案:

没有答案