2012-10-31 5 views
0

자바 스크립트에서 다음 코드는 실제 인쇄 대화 상자를 불러 오지 않습니다. 새 창이 열리지 만 인쇄 대화 상자는 표시되지 않습니다. IE/Chrome/mozilla는 괜찮습니다. Ive는 오페라에 대한 모든 일반적인 시간 초과 문제를 읽고 솔루션의 모든 가능성을 믿으려고 시도했습니다.asp.net 오페라 인쇄 대화 상자

누구나 해결책이 무엇인지 알 수 있습니까?

var windowUrl = 'about:blank'; 
var UserLoggedIn = $("#lblUser").text() 
var now = new Date(); 
var strDateTime = [ 
    [AddZero(now.getDate()), AddZero(now.getMonth() + 1), now.getFullYear()].join("/"), [AddZero(now.getHours()), AddZero(now.getMinutes())].join(":"), now.getHours() >= 12 ? "PM" : "AM"].join(" "); 
var Database = 'ProductionDatabase'; 
var windowName = 'Report'; 
var AuditPrintDetailEverypage = UserLoggedIn + ' Time : ' + strDateTime; 
var AuditPrintDetailLastPage = '  Report ' + ' Source Database: '; 
var WinPrint = window.open(windowUrl, windowName, 'left=300,top=300,right=500,bottom=500,width=1000,height=500,scrollbars=1'); 
WinPrint.document.write('<' + 'html' + '><head><link href="assets/css/Print.css" rel="stylesheet" type="text/css" /><title>' + AuditPrintDetailEverypage + '</title> </head><' + 'body style="background:none !important"' + '>'); 
WinPrint.document.write(printContent.innerHTML); 
WinPrint.document.write('   ' + AuditPrintDetailLastPage); 
WinPrint.document.write('<' + '/body' + '><' + '/html' + '>'); 
WinPrint.document.close(); 

if (window.opera) { 
    window.onload = function() { 
     window.setTimeout(function() { 
      window.print; 
     }, 500); 
    } 
} else { 
    WinPrint.focus(); 
    WinPrint.print(); 
    WinPrint.close(); 
} 
+4

isnt'window.print' 방법? 'window.print()'를 호출하면 안되나요? – Tejs

+2

그리고 WinPrint가 아니라'window'의'onload'도 설정하고 있습니다. 그 영역의 코드에서'window'의 모든 항목에'WinPrint'를 사용하고 싶지 않으십니까? (사실,'괜찮아요 (window.opera)'를 유지하십시오.) – Ian

+2

'about : blank'는 실제로 크로스 브라우저 솔루션이 아닙니다 (f.ex. opera는 내부적으로'opera : blank'로 리디렉션됩니다) - javascript : void (0)'대신에. – pozs

답변

0

일부 사이트와 달리 오페라에서는()가 중요합니다. 다른 사람에게 도움이되기를 바랍니다. 위의 친구들에게 답하십시오.

    if (window.opera) { 


         WinPrint.onload = function() { 
          WinPrint.setTimeout(function() { 
           WinPrint.print(); 
          }, 500); 
         }