1.2 自定义页面中使用 JS
通过获取 iframe 中的报表再使用 FineReport 的 JS 方法
如:报表嵌入在 iframe 的 id 为"reportFrame"时,调用报表的打印预览方法,如下:
document.getElementById('reportFrame').contentWindow.contentPane.printPreview();
引入 FineReport 的 js 文件再使用 FineReport 的 JS 方法
代码:
<script
type="text/javascript"
src="/WebReport/ReportServer?op=resource&resource=/com/fr/web/jquery.js"></script>
<script
type="text/javascript"
src="/WebReport/ReportServer?op=emb&resource=finereport.js"></script>
<script type='text/javascript'>
function doPrint(){
var url="http://localhost:8075/WebReport/ReportServer?reportlet=gettingstarted.cpt";//
端口和 ip 根据具体情况设定
FR.doURLFlashPrint(url);
}
</script>
要注意的是,如果该页面中引入了其他版本的 jquery.js,可能会有 JS 冲突,因此建议通过获
取 iframe 中的报表再使用 FineReport 的 JS 方法