我做了一个显示数据库中记录的页面,不过我用了框架,用IE的打印功能会打印整个页面,如果我想打印显示纪录的页面,而不是整个框架页面,怎么实现?在hotmail的信箱中有一个打印邮件的功能,我觉得和我的目的是一样的,请各位高手指点迷津!100送上!
---------------------------------------------------------------
在
1<head></head>
之间加入如下代码;
1<object classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" id="WB" width="0"></object>
1<script language="javascript">
2function doPrintSetup(){
3WB.ExecWB(8,1)
4}
5function doPrintPreview(){
6WB.ExecWB(7,1)
7}
8</script>
在
1<body>中调用:
2<input name="button1" onclick="return doPrintSetup()" type="button" value="打印设置"/>
3<input name="button2" onclick="return doPrintPreview()" type="button" value="打印预览"/>
4<input name="button3" onclick="javascript:print()" type="button" value="打印本页"/>
5
6\---------------------------------------------------------------
7
8function printPreview()
9{
10try
11{
12var printWindow = window.open("","_blank");
13var str = "<object classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" id="WebBrowser" width="0"></object>"
14var s = "<html>\r\n";
15s += "<head>";
16s += "<link href="../../pic/broker30.css" rel="stylesheet" type="text/css"/>";
17s += "<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>";
18s += "</head>";
19s += "<body><center><br/>";
20s += "<div align="center" style="width:96%">";
21s += document.body.innerHTML;
22s += "</div>";
23s += "</center></body>";
24s += "</html>";
25printWindow.document.write(s);
26printWindow.document.close();
27printWindow.document.body.insertAdjacentHTML("beforeEnd", str);
28printWindow.document.all.WebBrowser.ExecWB(7,1);
29printWindow.close();
30}
31catch(e)
32{
33alert("您的浏览器版本太低,请升级您的浏览器!");
34}
35}</body>