2008-09-11 [jquery.jPrintArea.js]
動きがバグバグだったので手を入れた。
jQuery.jPrintArea=function(el)
{
var iframe=document.createElement('IFRAME');
iframe.src="javascript:false;";
var doc=null;
$(iframe).attr('style', 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;');
document.body.appendChild(iframe);
var print=function() {
doc=iframe.contentWindow.document;
doc.write('' + document.title + ' ');
doc.write('');
var links=window.document.getElementsByTagName('link');
for(var i=0;i ');
doc.write('
jQuery.jPrintArea=function(el)
{
var iframe=document.createElement('IFRAME');
iframe.src="javascript:false;";
var doc=null;
$(iframe).attr('style', 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;');
document.body.appendChild(iframe);
var print=function() {
doc=iframe.contentWindow.document;
doc.write('
doc.write('');
var links=window.document.getElementsByTagName('link');
for(var i=0;i
'+$(el).html()+'
');
doc.close();
iframe.contentWindow.focus();
iframe.contentWindow.print();
}
timerID = setTimeout("print()", 1);
document.body.removeChild(iframe);
}
リリース直前に泣きが入る。
httpsで通信する場合、サブウィンドウの読み込みで初回にhttp通信が発生するらしい。
iframe.src="javascript:false;";
回避。
見た目に影響を与えるスクリプトはオブジェクトとして親からクローニングして渡す。
doc.write('');
回避。
アラート出さないとレンダリングが他の制御を上回って処理がバグる。
var print=function() {
}
timerID = setTimeout("print()", 1);
回避。
印刷用CSSとかもdivの擬似フレームで処理してると
ひょっとしたら利かない気がする。
うは。オレ賢い。
残業は続く。
2008-09-11 00:01
nice!(0)
コメント(0)
コメント 0