Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 由于最近的Windows更新,我需要更换iFrame打印_Javascript_Html_Iframe_Windows Update - Fatal编程技术网

Javascript 由于最近的Windows更新,我需要更换iFrame打印

Javascript 由于最近的Windows更新,我需要更换iFrame打印,javascript,html,iframe,windows-update,Javascript,Html,Iframe,Windows Update,我的web应用程序(java、jsp、js)中有一个按钮,它允许从屏幕的选定区域获取HTML,并将其放置在名为“iFramePrint”的iframe中,然后进行打印 <iframe name="iFramePrint" frameborder="0" src="Blank.jsp" marginheight="0" marginwidth="0" width="0" height="0"></iframe> function doPrint() { if (w

我的web应用程序(java、jsp、js)中有一个按钮,它允许从屏幕的选定区域获取HTML,并将其放置在名为“iFramePrint”的iframe中,然后进行打印

<iframe name="iFramePrint" frameborder="0" src="Blank.jsp" marginheight="0" marginwidth="0" width="0" height="0"></iframe>

function doPrint() {
    if (window.frames['iFramePrint'].document.body) {

        var str = '<B>'+'<h1>' + document.getElementById('tdMainTitle').innerHTML +'</h1>'+'</B>';
        str += '<BR>';
        etc.
        str=str.replace(/BORDER=0/g ,"border=1");
        window.frames['iFramePrint'].document.body.innerHTML = str; 
        window.frames['iFramePrint'].focus();
        window.frames['iFramePrint'].print(); 
    }
}

函数doPrint(){
if(window.frames['iFramePrint'].document.body){
var str=''+''+document.getElementById('tdMainTitle')。innerHTML+'';
str+='
'; 等 str=str.replace(/BORDER=0/g,“BORDER=1”); frames['iFramePrint'].document.body.innerHTML=str; frames['iFramePrint'].focus(); frames['iFramePrint'].print(); } }
这已经运行了很长一段时间,但是由于最近的Windows更新,代码不再工作。见下文

我最好不要等到微软来解决这个问题——可能需要一段时间。我不想要求客户端卸载KB402725(知识库的数量因windows版本而异,但一般来说,这是本月发布的7月份安全更新汇总),这确实解决了问题


我有一个解决方法——将HTML转换成PDF,然后允许用户下载PDF,这是完全可行的。请参阅-只是想知道是否有更好的方法。

到目前为止,我找到的最佳解决方案是用新窗口替换iFramePrint

function doPrint() {
        var str = '<B>'+'<h1>' + document.getElementById('tdMainTitle').innerHTML +'</h1>'+'</B>';
        str += '<BR>';
        etc.
        str=str.replace(/BORDER=0/g ,"border=1");
        w=window.open();
        w.document.write('<html><head><title>Printout</title>');
        w.document.write('</head><body >');
        w.document.write(str);
        w.document.write('</body></html>');
        w.document.close();
        w.focus();
        w.print();
        w.close();
}
函数doPrint(){
var str=''+''+document.getElementById('tdMainTitle')。innerHTML+'';
str+='
'; 等 str=str.replace(/BORDER=0/g,“BORDER=1”); w=window.open(); w、 文件。写入(“打印输出”); w、 文件。写(“”); w、 文件编写(str); w、 文件。写(“”); w、 document.close(); w、 焦点(); w、 打印(); w、 close(); }
感谢@pratik in和@jaay in 还有其他一些答案,它们可能会在不打开新窗口的情况下发挥作用

function doPrint() {
        var str = '<B>'+'<h1>' + document.getElementById('tdMainTitle').innerHTML +'</h1>'+'</B>';
        str += '<BR>';
        etc.
        str=str.replace(/BORDER=0/g ,"border=1");
        w=window.open();
        w.document.write('<html><head><title>Printout</title>');
        w.document.write('</head><body >');
        w.document.write(str);
        w.document.write('</body></html>');
        w.document.close();
        w.focus();
        w.print();
        w.close();
}