<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<OBJECT id=closes type=application/x-oleobject
classid=clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11><param name=Command value=Close></object>
<SCRIPT>
function window.onbeforeprint(){
alert("打印前事件");
}
function window.onafterprint(){
alert("打印后事件");
closes.Click();
}
</SCRIPT>
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=页面设置>
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,6) type=button value=打印预览>
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=页面打印>
</object>
<OBJECT id=closes type=application/x-oleobject
classid=clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11><param name=Command value=Close></object>
<SCRIPT>
function window.onbeforeprint(){
alert("打印前事件");
}
function window.onafterprint(){
alert("打印后事件");
closes.Click();
}
</SCRIPT>
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=页面设置>
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,6) type=button value=打印预览>
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=页面打印>
解决方案 »
- 如何优化10几个if语句?
- 大侠看看为什么这个插件改字体颜色不成功
- (软件开发)访问页面,打开ie浏览器时,设置浏览器的样式,窗口的工具栏,地址栏怎么样才能没有。而且无法放大缩小窗口大小。
- 好几天没想通的一个JavaScript菜单,SOS
- 急求能将阿拉伯数字转成中文大写的javascript函数
- 关于input, button
- jscript和javascript有什么区别
- javascript问题
- htm文件能不能被分页呀,我的htm文件太长了!
- 在JavaScript中调用new ActiveXObject("Scripting.FileSystemObject")会涉及安全问题吗?
- 我这样写为什么错了?
- WIN2003下RegExp对象的exec()方法的执行效率问题
<!-- IE5.5以上 -->
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>
<input type=button value=打印 onclick="document.all.WebBrowser.ExecWB(6,1)">
<input type=button value=直接打印 onclick="document.all.WebBrowser.ExecWB(6,6)">
<input type=button value=页面设置 onclick="document.all.WebBrowser.ExecWB(8,1)">
<input type=button value=打印预览 onclick="document.all.WebBrowser.ExecWB(7,1)">
哪位大哥帮帮我吧!
framename指的是iframe的ID
用这个:
<script>
document.frames("ifrm").document.execCommand("Print", false);//"ifrm"为iframe的ID
</script>
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>
<input type=button value=页面设置 onclick="document.frames("ifrm").document.WebBrowser.ExecWB(8,1)">
<input type=button value=打印预览 onclick="document.frames("ifrm").document.WebBrowser.ExecWB(7,1)">
----------------------
var strObject="<OBJECT ID=\"pt\" CLASSID=\"CLSID:B43D3361-D975-4BE2-87FE-438AB8E74394\" codebase=\"brochuremachine.cab\" VIEWASTEXT></OBJECT>";
//var ptc=document.createElement(strObject);
var printerCTL=oDoc.getElementById("pt");
try {
if ( ! printerCTL){
oDoc.body.insertAdjacentHTML("beforeEnd",strObject);
}
var printerCTL=oDoc.all.pt;
printerCTL.SetFilePath("http://blueswing.vicp.net/PrintTemplate/xp/pt.htm");
printerCTL.LaunchPT();
}
catch(e){
alert("打印预览过程中出现错误");
}oDoc就是iframe的document对象,你可以通过对于iframe页面动态插入控件,然后调用其方法来实现的
我用了你的方法,其中的打印预览无法实现,报错为:未知错误!<input type=button value=打印预览 onclick="document.all.WebBrowser.ExecWB(7,1)">
怎样对iframe页面动态插入控件?
我的iframe的ID为ifrm1,用ifrm1.body.insertAdjacentHTML("beforeEnd",strObject);提示ifrm1.body为空或不是对象.
<input type=button value="横向打印">
<input type=button value="纵向打印">
不用提示用户再次设置,直接按照按钮提示打印