下面是print.js中的一段代码,本身没有问题,在网页test.jsp中引入print.js,单击按钮调用方法printHidden(url) 可以正常的打印.但是把test.jsp放入另外一个页面的框架之后,就出现问题了,打印机本身可以启动打印,但是打印出来是空白。求指点。万分感谢!
 
//下面是print.js中的代码 
 function printFrame(frame, onfinish) { 
  
  
  
 function execOnFinish() { 
         switch (typeof (onfinish)) { 
         case "string": 
             execScript(onfinish); 
             break; 
         case "function": 
             onfinish(); 
 } 
  if ( focused && !focused.disabled ) focused.focus(); 
  } 
  if ((frame.document.readyState !== "complete") 
             && (!frame.document.confirm("待打印的文档还未下载完成,是否确认继续打印?"))) { 
         execOnFinish(); 
         return; 
     } 
  
  var eventScope = printGetEventScope(frame); 
  var focused = document.activeElement; 
  
  window.printHelper = function() { 
         execScript("on error resume next: printWB.ExecWB 6, 2", "VBScript"); 
         printFireEvent(frame, eventScope, "onafterprint"); 
         printWB.outerHTML = ""; 
         execOnFinish(); 
         window.printHelper = null; 
     } 
  
  document.body.insertAdjacentHTML("beforeEnd", 
  "<object id=\"printWB\" width=0 height=0 \ 
  classid=\"clsid:8856F961-340A-11D0-A96B-00C04FD705A2\">"); 
  
  printFireEvent(frame, eventScope, "onbeforeprint"); 
  frame.focus(); 
  window.printHelper = printHelper; 
  setTimeout("window.printHelper()", 0); 
 } 
  
  
 function printIsNativeSupport() { 
  var agent = window.navigator.userAgent; 
  var i = agent.indexOf("MSIE ")+5; 
  return parseInt(agent.substr(i)) >= 5 && agent.indexOf("5.0b1") < 0; 
 } 
 function printFireEvent(frame, obj, name) { 
  var handler = obj[name]; 
  switch ( typeof(handler) ) { 
  case "string": frame.execScript(handler); break; 
  case "function": handler(); 
  } 
 } 
  
 function printGetEventScope(frame) { 
  var frameset = frame.document.all.tags("FRAMESET"); 
  if ( frameset.length ) return frameset[0]; 
  return frame.document.body; 
 } 
  
 //后台打印,打印URL指定的内容 
 function printHidden(url) { 
     try{ 
         pagesetup_null(); 
         document.body.insertAdjacentHTML("beforeEnd", 
         "<iframe name=printHiddenFrame width=0 height=0></iframe>"); 
         var doc = printHiddenFrame.document; 
         doc.open(); 
         doc.write("<body onload=\"parent.onprintHiddenFrame()\">"); 
         doc.write("<iframe name=printMe width=0 height=0 src=\"" + 
         url + "\"></iframe>"); 
         doc.write("</body>"); 
         doc.close(); 
     }catch(e){ 
         alert(e.name+":"+e.message); 
     } 
 } 
  
  
 function onprintHiddenFrame() { 
     function onfinish() { 
         printHiddenFrame.outerHTML = ""; 
         alert("打印请求已经发送到后台"); 
         if (window.onprintcomplete){ 
             window.onprintcomplete(); 
         } 
     } 
     printFrame(printHiddenFrame.printMe, onfinish); 
 }