IE本身功能(如打印,前进,后退,设成主页....)
1.在<head></head>之间加入如下代码;
<OBJECT Classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WB width=0></OBJECT>
<script language=javascript>
function doPrintSetup(){
WB.ExecWB(8,1)
}
function doPrintPreview(){
WB.ExecWB(7,1)
}
</script>
在<body>中调用:
<input type=button name=button1 value="打印设置" onclick="return doPrintSetup()">
<input type=button name=button2 value="打印预览" onclick="return doPrintPreview()">
<input type=button name=button3 value="打印本页" onclick="javascript:print()">
2.在<head></head>之间加入如下代码
<script language="javascript">
function preview()
{
bdhtml=window.document.body.innerHTML;
sprnstr="<!--startprint-->";
eprnstr="<!--endprint-->";
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML=prnhtml;
window.print();
//prnform.htext.value=prnhtml;
//prnform.submit();
//alert(prnhtml);
}
</script>
///////
<center>本部分以上不被打印</center>
<!--startprint-->
<table width="84%" align="center" bgcolor="#0000FF" cellpadding="2" cellspacing="1">
<tr bgcolor="#6699FF">
<td>
<div align="center">标题一</div>
</td>
<td>
<div align="center">标题二</div>
</td>
<td>
<div align="center">标题三</div>
</td>
<td>
<div align="center">标题四</div>
</td>
<td>
<div align="center">标题五</div>
</td>
</tr>
<tr bgcolor="#6699FF">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<!--endprint-->
<center>本部分以下不被打印</center>
<div align="center">
<input type="button" name="print" value="预览并打印" onclick="preview()">
</div>
3.其他功能
<input type=button value=刷新 onclick=window.location.reload()>
<input type=button value=前进 onclick=history.go(1)>
<input type=button value=后退 onclick=history.go(-1)>
<input type=button value=前进 onclick=history.forward()>
<input type=button value=后退 onclick=history.back()>
<input type=button value=导入收藏夹 onclick=window.external.ImportExportFavorites(true,"http://localhost");>
<input type=button value=导出收藏夹 onclick=window.external.ImportExportFavorites(false,"http://localhost");>
<input type=button value=整理收藏夹 onclick="window.external.ShowBrowserUI('OrganizeFavorites', null)">
<input type=button value=查看源文件 onclick="window.location = 'view-source:'+ window.location.href">
<input type=button value=语言设置 onclick="window.external.ShowBrowserUI('LanguageDialog', null)">
<input type=button value=加入收藏夹 onclick="window.external.AddFavorite('http://www.microsoft.com/', 'Microsoft Web')">
<input type=button value=加入到频道 onclick="window.external.addChannel('http://www.microsoft.com/')">
<input type=button value=设成主页 onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.microsoft.com/')">
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0 VIEWASTEXT></OBJECT>
<input type=button value=打开 onclick=document.all.WebBrowser.ExecWB(1,1)>
<input type=button value=另存为 onclick=document.all.WebBrowser.ExecWB(4,1)>
<input type=button value=全选 onclick=document.all.WebBrowser.ExecWB(17,1)>
<input type=button value=属性 onclick=document.all.WebBrowser.ExecWB(10,1)>
<input type=button value=关闭窗口 onclick=document.all.WebBrowser.ExecWB(45,1)>
<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)>
<OBJECT id="min" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" VIEWASTEXT><PARAM name="Command" value="Minimize"></OBJECT>
<input type=button value="Min" onclick="min.Click()">
<OBJECT id="max" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" VIEWASTEXT><PARAM name="Command" value="Maximize"></OBJECT>
<input type=button value="Max/Restore" onclick="max.Click()" id=button1 name=button1>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构