日期:2014-05-17  浏览次数:20718 次

怎么在模态窗口(showModalDialog)调用打印预览
弹出的模态窗口(子窗口)中调用IE的打印预览功能,结果IE弹出错误:“当前页面发生脚步错误...错误:不支持该命令 代码:0”, 
   
  我的打印预览代码如下(打印没问题): 
<OBJECT classid='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2' height=0 id=wb name=wb width=0> </OBJECT> 
<div style="margin-left:150px"> 
<input type='button' name='Submit1' value='- 打印 -' onclick='window.print();' class='noprint'/> 
<input type='button' name='Submit2' value='-打印预览-' onclick='wb.execwb(7,1);' class='noprint'/> 
   
   
  请朋友们共同研究. 


  如果不用模态窗口(showModalDialog)打印预览是可以的 



母窗口代码 
a.html
HTML code


<HTML>
<HEAD>
<TITLE>showModelessDialogEX.htm</TITLE>
<SCRIPT>
var sUserName="";
function fnCallDialog()
{ 
showModalDialog("b.html",window,"status:false;dialogWidth:300px;dialogHeight:300px");
}
function fnUpdate()
{ 
oName.innerText = sUserName;
}
</SCRIPT>
</HEAD>
<BODY>
<P>Enter your first name: <SPAN ID="oName" STYLE="color:red;font-size:24">Joan</SPAN></P>
<INPUT TYPE="button" VALUE="Display Modeless Dialog" onClick="fnCallDialog()">
</BODY>
</HTML>





子窗口代码: 
b.html
HTML code

<HTML> 
<HEAD>
<TITLE>myDialog.htm</TITLE>
<SCRIPT> 
function fnGetInfo() { 
var sData = dialogArguments; //父窗口
sData.sUserName = oEnterName.value; 
sData.fnUpdate(); 
}
function fnCancel() { 
var sData = dialogArguments; 
sData.sUserName = "Joan"; 
sData.fnUpdate(); 
}
</SCRIPT>
</HEAD> 
<BODY>
<LABEL FOR="oEnterName" ACCESSKEY="f">
Enter your <SPAN STYLE="text-decoration:underline">F</SPAN>irst Name</LABEL>
<OBJECT classid='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2' height=0 id=wb name=wb width=0></OBJECT>
<INPUT ID=oEnterName><BR><BR>
<INPUT VALUE="Apply" TYPE=button onClick="fnGetInfo();"> 
<INPUT VALUE="Ok" TYPE=button onClick="fnGetInfo();window.close();"> 
<INPUT VALUE="Cancel" TYPE=button onClick="fnCancel();window.close();"> 
<input type='button' name='Submit2' value='-打印预览-' onclick='wb.execwb(7,1);' class='noprint'/>
</BODY> 
</HTML>




------解决方案--------------------
探讨
<input  type=button  value=打印预览  onclick=document.all.WebBrowser.ExecWB(7,1)> 


这样就可以了哦,具体的看这里,有打印,直接打印,页面设置,打印预览等功能:打印功能实现

------解决方案--------------------
pdf打印解决