【问题标题】:Jquery jFrame not working in IE but is in FFJquery jFrame 在 IE 中不起作用,但在 FF 中
【发布时间】:2013-08-13 18:38:46
【问题描述】:

嘿,我正试图让这个 jFrame 在 IE8/9 中工作,因为它在 FF 中工作没有问题。

打印图像的代码是这样的:

function PrintElem(elem) 
{ 
var strFrameName = ("printer-" + (new Date()).getTime());
var jFrame = $( "<iframe name='" + strFrameName + "'>" );

jFrame
    .css( "width", "1px" )
    .css( "height", "1px" )
    .css( "position", "absolute" )
    .css( "left", "-9999px" )
    .appendTo( $( "body:first" ) )
;

var objFrame = window.frames[ strFrameName ];
var objDoc = objFrame.document;
var theHTML = $(elem).html();

theHTML = theHTML.replace("display:none","display:inline"); 
objDoc.open();
objDoc.write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" );
objDoc.write( "<html>" );
objDoc.write( "<body>" );
objDoc.write( "<head>" );
objDoc.write( "</head>" );
objDoc.write(theHTML);
objDoc.write( "</body>" );
objDoc.write( "</html>" );
objDoc.close();
objFrame.focus();
objFrame.print();
}

我开始这样做了:

 <div id="printable"><IMG SRC="picturesFromServer.asp?PhotoId=310481" style="display:none;"></div>
 <IMG SRC="picturesFromServer.asp?PhotoId=310481" width="240" height="320"><br>
 </form>

 <input type="button" value="Print Division" onclick="PrintElem('#printable')" /> 

它在 FF 中很好地显示页面并打印它,但在 IE 中它只显示当前页面。

我正在使用从该网站找到的 jFrame 代码:http://www.bennadel.com/blog/1591-Ask-Ben-Print-Part-Of-A-Web-Page-With-jQuery.htm

帮助会很大!

大卫

【问题讨论】:

标签: jquery css internet-explorer firefox printing


【解决方案1】:

试试

jFrame.css( "opacity", "0" ).css( "height", "0px" ).appendTo($("body:first"));

它对我有用。显示:无;不会被 ie 识别。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-12
    相关资源
    最近更新 更多