会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
网站开发与移动开发
博客园
首页
新随笔
管理
公告
jquery/js 实现 标签 条码 一维码 Web页面 区域打印解决方案 实例
//打印页面区域方式一:给body添加visibility:hidden;隐藏标记,给要打印的部分添加visibility:visible;显示标记 function printTag1(){ $("#entityForm").css("display","none"); $("#tagImgView").css("display","block"); window.print(); $("#entityForm").css("display","block"); }
//区域打印方式二:仅仅打印标签部分 function printTag2() { 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(); }
<form action="" name="entityForm" id="entityForm" target="result" method="post" onsubmit="return checkInfo();"> <input type="hidden" name="id" id="id" value="${tag.id }" /> <table border="0" cellpadding="0" cellspacing="0"> <tr class="main_info"> <td colspan="4"><div id="receipt_title" class="receipt_main_title">一维标签管理</div></td> </tr> <tr class="info"> <!-- <th>标签名称:</th> <td><input type="text" name="name" id="name" class="input_txt" value="${tag.name }" /></td> --> <th>标签编号:</th> <td><input type="text" name="code" id="code" onkeyup="value=value.replace(/[\W]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" class="input_txt" value="${tag.code }" /></td> <td colspan="2"></td> </tr> <tr class="info"> <td colspan="1"></td> <td colspan="2"><a href="javascript:createTag();" id="createTag" class="myBtn"><em>生成标签</em> </a> <a href="javascript:saveTag();" id="saveTag" class="myBtn"><em>保存标签</em> </a></td> <td colspan="1"></td> </tr> <tr class="info"> <td colspan="2">标签预览:</td> <td colspan="2"><a href="javascript:printTag1();" id="printTag" class="myBtn"><em>打印标签</em> </a> </td> </tr> </table> </form> <div id="preview"> <div class="info"> <!--startprint--> <img id="tagImgView" class="PrintOnly" src="${ctx }/tag/barcode?msg=12345678&encode=utf-8&type=code39" /> <!--endprint--> </div> </div>
条码生成采用的开源jar包:barcode4j
posted on
2012-06-18 15:35
txf2004
阅读(
568
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
Powered by:
博客园
Copyright © 2024 txf2004
Powered by .NET 8.0 on Kubernetes