小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Javascript window.open和print導致IE8掛起

 印度阿三17 2019-09-03

我正在嘗試使用window.open()創(chuàng)建一個然后打印的彈出窗口,但是我遇到問題,IE8掛起后彈出它.

更多詳情:

在我的應用程序結束時,我正在嘗試打印輸出的信息,但我試圖在該彈出窗口中包含單獨的CSS,jQuery和Javascript.我認為正是這些外部鏈接導致IE8掛斷,但我不確定.

在我測試的所有其他瀏覽器中發(fā)生的事情是彈出窗口,出現打印對話框,打印正常.

在IE8中,窗口彈出,內容出現,CSS似乎加載,但不是Javascript.如果您嘗試手動打印(Ctrl P),它將打印而不使用CSS.

我試過這里的例子:
Script elements written with document.write in a window opened with window.open are not executed in IE8 on Windows 7

現場演示

如果您想查看實時版本,請訪問:http:///
如果您想要到達打印部分,則必須填寫應用程序所需的信息. (第二步,只需填寫無線電輸入).

要查看完整的javascript:http:///js/scripts.js,您將在其中找到我嘗試過的其他方法.

將元素傳遞給函數

$('#actionPrint').live('click', function(event){
    printElem('#rc');
}

彈出元素并打印出來.

function printElem(elem) {
    popup($j(elem).html());
}

 function popup(data) {
    var mywindow = window.open('', 'printSheet', 'height=500,width=800,scrollbars=1');
    mywindow.document.open();
    mywindow.document.write('<html><head><title>Roxul Insulation Calculator</title>');
    mywindow.document.write('</head><body>');
    mywindow.document.write('<div id="rc_logo"><img src="img/roxul-logo.png" alt="roxul-logo" /></div>');
    mywindow.document.write(data);
    mywindow.document.write('</body></html>');

    var c = mywindow.document.createElement("link");
        c.rel = "stylesheet";
        c.type = "text/css";
        c.href = "css/print.css";
        mywindow.document.getElementsByTagName("HEAD")[0].appendChild(c);

    var s = mywindow.document.createElement("script");
        s.type = "text/javascript";
        s.src = "js/jquery-1.5.2.min.js";
        mywindow.document.getElementsByTagName("HEAD")[0].appendChild(s);

    var s2 = mywindow.document.createElement("script");
        s2.type = "text/javascript";
        s2.src = "js/print.js";
        mywindow.document.getElementsByTagName("HEAD")[0].appendChild(s2);

    mywindow.print();
    return true;
 }

解決方法:

我已經解決了我自己的問題,所以希望回答一個人自己的問題并不是壞事.

我的錯誤不包括mywindow.document.close();在我的功能結束時.
現在看起來如下:

mywindow.print();
mywindow.document.close();
return true;

我與其中一位與我合作的開發(fā)人員交談,他說document.close()會釋放要打印的資源.

來源:https://www./content-1-437201.html

    本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯系方式、誘導購買等信息,謹防詐騙。如發(fā)現有害或侵權內容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多