html怎么打印

html-css010

html怎么打印,第1张

需要准备的材料分别有:电脑、chrome浏览器、打印机。

1、首先,打开想要打印的html网页,例如:zhidao.baidu.com。

2、在网页中,鼠标右键空白处,点击打印按钮。

3、此时会弹出打印面板,点击“打印”按钮即可完成打印。

<HTML><HEAD><TITLE>打印-页面设置-打印预览-关闭窗口</TITLE>

<SCRIPT language=javascript>

function printsetup()

{

// 打印页面设置

wb.execwb(8,1)

}

function printpreview()

{

var ht1 = document.getElementByIdx_x("h")

ht1.style.display="none"//隐藏不必打印的部分,该隐藏只在预览中有效,真正打印时要用css控制

wb.execwb(7,1)// 打印页面预览

ht1.style.display="" //预览完再将隐藏的部分显示出来

}

function printit()

{

 if (confirm('确定打印吗?'))

{

wb.execwb(6,6)

}

}

</script>

<style type="text/css" media=print>

.noprint{display : none } //不打印

</style>

</HEAD>

<BODY>

<!-- div h 中的内容不打印 -->

<DIV id="h" align=center class="noprint">

<OBJECT id=wb height=0 width=0 classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2></OBJECT>

<INPUT onclick=javascript:printit() type=button value=打印 />

<INPUT onclick=javascript:printsetup()type=button value=打印页面设置 />

<INPUT onclick=javascript:printpreview()type=button value=打印预览 />

<INPUT onclick=javascript:window.close()type=button value=关闭 />

</DIV>

要打印的正文

</BODY>

</HTML>