window.open()を使用してプリントを作成しようとしていますが、IE8がポップアップした後に問題が発生しています。Javascript window.openとprint IE8がハングする原因
もっと詳しく:
私のアプリの終わりに、私は、出力された情報を印刷しようとしていますが、私はそのポップアップで別のCSS、jQueryとJavascriptを含めるしようとしています。私はそれがIE8をハングアップさせているこれらの外部リンクだと思うが、わからない。
私がテストした他のすべてのブラウザでは、ウィンドウがポップアップし、印刷ダイアログが表示され、問題なく印刷されます。
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://roxulmaterialscalculator.com/ あなたが記入する必要があります、ここでの例以下
私が試してみましたがあなたが印刷部分に到達したい場合、アプリケーションが必要とする情報。 (2番目のステップでは、ラジオ入力を入力するだけです)。
完全なjavascript:http://roxulmaterialscalculator.com/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;
}
私はちょうど推測ですが、印刷するように言う前にウィンドウが実際には読み込まれていない可能性があります。 '
'と頭にそれらのjsファイルを読み込むのをスキップしてください(もしあなたが印刷しているのであれば、ポップアップで何かのためにjQueryが必要なのか疑問です) – Flambino