2010-01-27 8 views

답변

2

인쇄의 경우 window.print()을 사용할 수 있습니다.

저장 대화 상자를 트리거하는 표준 방법은 없습니다. IE에서는 document.execCommand('SaveAs')을 사용할 수 있습니다.

편집는 : 기술적으로 window.print은 표준 (출처 : MDC)의 일부가 아닙니다하지만 광범위하게 사용할 수 있습니다.

1

시도는 (이것은 단지 "다른 이름으로 저장"을위한) 찢어 here

<html> 
<head> 

<script src="http://code.jquery.com/jquery-latest.js"></script> 

<script > 
$(document).ready(function(){ 
$('a#save').click(function() { 
     if (!!window.ActiveXObject) { 
      document.execCommand("SaveAs"); 
     } else if (!!window.netscape) { 
      var r=document.createRange(); 
      r.setStartBefore($("head")[0]); 
      var oscript=r.createContextualFragment('<script id="scriptid" type="application/x-javascript" src="chrome://global/content/contentAreaUtils.js"><\/script>'); 
      $('body').append(oscript); 
      r=null; 
      try { 
       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
       saveDocument(document); 
      } catch (e) { 
       //no further notice as user explicitly denied the privilege 
      } finally { 
       //re-defined 
       $("#scriptid").remove(); 
      } 
     } 
    return false; 
    }) 
}) 
</script> 
</head> 
<body> 
<a href="#" id="save">save the document</a> 
</body> 
</html> 
에서 편집
관련 문제