我想通过iframe来打印一个pdf文件,但是有时候浏览器会警告 Resource interpreted as Document but transferred with MIME type application/pdf 。通过测试是能打印的,但是偶尔就会报这个警告不能打印,出现警告无规律,点几次就出。function test(){ var iframe = document.getElementById("printIframe"); iframe.type="application/pdf"; document.getElementById("printIframe").src = 'GWTJM.pdf'; if (iframe.attachEvent){ iframe.attachEvent("onload", function(){ // alert("Local iframe is now loaded."); document.getElementById("printIframe").contentWindow.print(); }); } else { iframe.onload = function(){ // alert("Local iframe is now loaded."); document.getElementById("printIframe").contentWindow.print(); }; } }
添加回答
举报
0/150
提交
取消