如何在Firefox中打印PDF?
此功能适用于Chrome,但不适用于Firefox
function print_pdf(url){
var id = 'iframe', html = '<iframe id="'+id+'" src="'+url+'" style="display:none"></iframe>';
$('#main').append(html);
$('#'+id).load(function(){
document.getElementById(id).contentWindow.print();
}
}
Run Code Online (Sandbox Code Playgroud)
Error: Permission denied to access property "print"
Run Code Online (Sandbox Code Playgroud) 我知道如何在新窗口中打开网页并添加javascript,以便弹出打印对话框.有没有办法用PDF文件做类似的事情?
需要帮忙
我需要iframe在点击时加载PDF ,然后在其上调用打印对话框.
我有这样的代码:
$('.print').click(function () {
var iframe = '<iframe src="test.pdf" id="print-iframe" name="print-iframe"></iframe>';
$('body').append(iframe);
window.frames["print-iframe"].focus();
window.frames["print-iframe"].print();
});
Run Code Online (Sandbox Code Playgroud)
它在Chrome中完美运行.但在Firefox中我有这样一个错误:
Error: Permission denied to access property 'print'.
我该如何解决这个问题?谢谢!
我的jsp页面中有一个链接.
链接看起来像这样
<a href="javascript:doSomething('abc.ff' , 'abc.ff?m=1')">
Run Code Online (Sandbox Code Playgroud)
javascript代码
function doSomething(url, url_progress){
parent.win1.location.href = url;
/* Wait until something surely has started! */
window.setTimeout("this.startFinally()", 1000);
this.startFinally = function (){
location.href = url_progress;
}
}
Run Code Online (Sandbox Code Playgroud)
当用户碰到这个碰撞时,一切正常.最近我把这个代码放在一个iframe中然后没有任何反应.我检查了firebug并得到了这个错误:
Permission denied to access property 'win1'
[Break On This Error] parent.win1.location.href = url;
Run Code Online (Sandbox Code Playgroud)
可能是什么问题?