
标题: jatoolsprinter打印iframe嵌套内容(转自csdn) [打印本页]
	
	作者: admin    时间: 2015-4-29 09:31	     标题: jatoolsprinter打印iframe嵌套内容(转自csdn)	
			原文   
http://blog.csdn.net/flm_0722/article/details/7460744复制内容到剪贴板
代码:
<span style="font-size:16px;"><html>
<head>
    <title>打印</title>
    <!-- 插入打印控件 -->
    <script src="jquery-1.4.2.js" type="text/javascript"></script>
    <OBJECT ID="jatoolsPrinter" CLASSID="CLSID:B43D3361-D075-4BE2-87FE-057188254255" codebase="jatoolsPrinter.cab#version=5,7,0,0"></OBJECT>
    <script type="text/javascript">
            $(function(){
                    window.showForm.location = sys_ctx+"/form/default.do?method=showFormReferencedata&tableid="+tableid+"&guid="+ywslid;
                    
                    //打印
                    $("#btn_print").click(function(){
                            //打印文档对象
                            var myDoc ={ 
                                settingsID:"mysettings1", //每个功能模块应使用不同的设置
                                    //documents: document,    // 打印页面(div)们在本文档中
                                documents: window.frames["showForm"].document,    // 打印iframe页面(div)们在本文档中
                                    copyrights  :    '杰创软件拥有版权  www.jatools.com'         // 版权声明必须
                            };
                            myDoc.done=function(){ 
                                   //window.close();
                                   //$("body").html(bodyhtml);
                            } 
                            // 调用打印方法
                                   jatoolsPrinter.print(myDoc ,false);       // 不弹出对话框打印
                    });
                    
                    //预览
                    $("#btn_preview").click(function(){
                            //打印文档对象
                            var myDoc ={ 
                                settingsID:"mysettings1", //每个功能模块应使用不同的设置
                                //documents: document,    // 打印页面(div)们在本文档中
 documents: window.frames["showForm"].document, // 打印iframe页面(div)们在本文档中 copyrights : '杰创软件拥有版权 www.jatools.com' // 版权声明必须 }; myDoc.done=function(){ //window.close(); //$("body").html(bodyhtml); } // 调用打印方法 jatoolsPrinter.printPreview(myDoc,true ); // 打印预览 }); }); </script></head>
<body>
<!-- 按钮 -->
<div id="div_button" class="c_table_bar_content" align="center">
        <input type="button" id="btn_preview" name="btn_preview" value="预览"/>
    <input type="button" id="btn_print" name="btn_print" value="打印"/>
</div>
<!-- 表单 iframe -->
<div id="div_form" class="c_table_bar_content" align="center">
    <iframe id="showForm" name="showForm" src="" frameborder='no' border='0' marginwidth="0" marginheight="0" width="100%" height="800" scrolling="auto"></iframe>
</div></span>被打印的内容要加到要打印内容。。。
里面
这样打印时就可以将iframe嵌套内容打印出来
| 欢迎光临 杰表技术论坛  (http://bwtvl16d.jatools.com/) | Powered by Discuz! 6.1.0 |