0
嘿,我想讓這個jFrame在IE8/9中工作,因爲它在FF中工作沒有問題。jquery jFrame不工作在IE中,但在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
,並幫助將是巨大的!
大衛
看看http://projects.erikzaadi.com/jQueryPlugins/jQuery.printElement/,它也適用於Firefox。 – arunes 2012-03-01 11:11:52
@arunes:這似乎沒有工作的一半時間我測試演示網站出來... – StealthRT 2012-03-01 23:10:48