我一直在爲此付出一段時間,並決定是時候尋求幫助。使用javascript寫入新窗口...獲取訪問被拒絕
我想創建一個aspx頁面上的打印功能,我使用JavaScript來做到這一點:
function PrintContentCell() {
var display_setting = "toolbar=yes, location=no, directories=yes, menubar=yes,";
display_setting += "scrollbars=yes, width=750, height=600, left=100, top=25";
var content_innerhtml = document.getElementById("testTable").innerHTML;
var document_print = window.open("Loading.htm", "", display_setting);
document_print.document.open();
document_print.document.write('<html><head><title>Print</title></head>');
document_print.document.write('<body style="font-family:verdana; font-size:12px;" onLoad="self.print();self.close();" >');
document_print.document.write(content_innerhtml);
document_print.document.write('</body></html>');
document_print.print();
document_print.document.close();
return false;
}
我得到「拒絕訪問」,當腳本嘗試寫入新的窗口。 Loading.htm文件只是一個非常苗條的HTML文檔,寫出文本「正在加載...」。我本來希望看到這個線程後,這將工作:IE 6/7 Access Denied trying to access a popup window.document
任何人都可以幫忙嗎?
它看起來像你試圖打開/關閉在彈出窗口通過onload *和*從開瓶器窗口。這是故意的嗎? – scunliffe 2010-04-09 10:52:54
你好。你是對的,它應該足以讓他們在onLoad事件中。我剛從這個頁面複製了這個測試的大部分腳本:http://nice-tutorials.blogspot.com/2009/05/print-using-javascript.html – Sohape 2010-04-12 06:50:22