日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

Javascript window.open和print導(dǎo)致IE8掛起

 印度阿三17 2019-09-03

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

更多詳情:

在我的應(yīng)用程序結(jié)束時(shí),我正在嘗試打印輸出的信息,但我試圖在該彈出窗口中包含單獨(dú)的CSS,jQuery和Javascript.我認(rèn)為正是這些外部鏈接導(dǎo)致IE8掛斷,但我不確定.

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

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

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

現(xiàn)場(chǎng)演示

如果您想查看實(shí)時(shí)版本,請(qǐng)?jiān)L問:http:///
如果您想要到達(dá)打印部分,則必須填寫應(yīng)用程序所需的信息. (第二步,只需填寫無(wú)線電輸入).

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

將元素傳遞給函數(shù)

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

彈出元素并打印出來(lái).

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;
 }

解決方法:

我已經(jīng)解決了我自己的問題,所以希望回答一個(gè)人自己的問題并不是壞事.

我的錯(cuò)誤不包括mywindow.document.close();在我的功能結(jié)束時(shí).
現(xiàn)在看起來(lái)如下:

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

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

來(lái)源:https://www./content-1-437201.html

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多