js 打印 iframe div 内容

function doPrint(){
        var turl = document.getElementById("iframeid").src;
        var newW = window.open(turl);
        newW.print();
}

类似还有:获取某个空间的值,然后打印

查看样例

详细代码:

<div id='contect'>
ssssssssss
</div>
<script type="text/javascript">
/*<![CDATA[*/
print_ele_f('contect');
function print_ele_f(id_s)
{
  var ele = document.getElementById(id_s);
      
  var w = window.open('about:blank');
  setTimeout(function(){
  w.document.body.innerHTML = ele.innerHTML;
  w.print();},100)
}
/*]]>*/
</script>

你可能感兴趣的:(iframe)