1
내 응용 프로그램에서 팝업 창을 통해 일부 데이터를 인쇄 중입니다. 팝업로드시 사용자에게 인쇄 또는 취소하라는 메시지가 표시됩니다. 클릭 한 버튼에 따라 어떤 조치를 취할 수 있도록 어떤 버튼이 클릭되었는지 (인쇄 또는 취소) 알고 싶습니다. 코드와 스크린 샷은 다음과 같습니다.웹 브라우저의 인쇄 팝업에서 클릭 (확인 또는 취소) 이벤트를 알 수있는 방법
public void Print(int Id)
{
StringBuilder sb = BadgeHelper.preparePrintableString(Id);
string printWindowFunc = "function printWindow() {\n" +
"var z = window.print();\n alert('Return: ' + z);\n" +
"checkDocumentState();\n" +
"}";
string checkDocumentStateFunc = "function checkDocumentState() {\n" +
"if (document.readyState == 'complete') {\n" +
"window.close();\n" +
"}\n" +
"else {\n alert('Else');\n" +
"setTimeout('checkDocumentState()', 2000);\n" +
"}\n"+
"}\n";
string startingHTMLCode = "<html>\n" +
"<head>\n" +
"<script type='text/javascript'>\n " +
checkDocumentStateFunc +
"\n" +
printWindowFunc +
"</script>\n " +
"</head>\n" +
"<body onload='printWindow();'>\n";
sb.Insert(0, startingHTMLCode);
sb.Append("\n</body>\n</html>");
Response.Write(sb.ToString());
}
확인이 : http://stackoverflow.com/questions/1692668/find-whether-save-or-cancel-button-is-clicked-on-print -dialog-box – ionden
좋은 질문이지만, 이것이 1) '공정한'js 2)에서 가능하지 않다는 생각이 들기는합니다. (너무 똑똑하고 활동적인 인터페이스에 대한 제 개인적 증오입니다.) –
'onbeforeprint/onafterprint'는 인쇄 상태를 확인하거나'window.print' 결과를 반환 할 수 없습니다. – kirilloid