栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在JavaScript中打印呈现的HTML页面的一部分?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在JavaScript中打印呈现的HTML页面的一部分?

我会这样处理:

<html>    <head>        <title>Print Test Page</title>        <script> printDivCSS = new String ('<link href="myprintstyle.css" rel="stylesheet" type="text/css">') function printDiv(divId) {     window.frames["print_frame"].document.body.innerHTML=printDivCSS + document.getElementById(divId).innerHTML;     window.frames["print_frame"].window.focus();     window.frames["print_frame"].window.print(); }        </script>    </head>    <body>        <h1><b><center>This is a test page for printing</center></b><hr color=#00cc00 width=95%></h1>        <b>Div 1:</b> <a href="javascript:printDiv('div1')">Print</a><br>        <div id="div1">This is the div1's print output</div>        <br><br>        <b>Div 2:</b> <a href="javascript:printDiv('div2')">Print</a><br>        <div id="div2">This is the div2's print output</div>        <br><br>        <b>Div 3:</b> <a href="javascript:printDiv('div3')">Print</a><br>        <div id="div3">This is the div3's print output</div>        <iframe name="print_frame" width="0" height="0" frameborder="0" src="about:blank"></iframe>    </body></html>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/416057.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号