H5 嵌入条码和二维码生成

效果动画演示

 

 实现步骤

第一步:创建窗口“H5”

第二步:找到对应的H5处理页面(自己可以自行开发,或开发打印功能都可以的)

 Html5页面对应的页面代码如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>条码和二维码生成器</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="generator" content="pandoc" />
    <meta name="date" content="" />
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="jquery.qrcode.min.js"></script>
    <script type="text/javascript" src="jquery.qrcode.js"></script>
    <script type="text/javascript" src="qrcode.js"></script>
    <script type="text/javascript" src="JsBarcode.all.min.js"></script>
</head>
<body style="overflow:hidden;">
    <p></p>
    <div style="width:90%; text-align:center;">
        <img id="qrcodeTiaoMa" style="width:400px;" />
    </div>
    <p></p>
    <div style="width:90%; text-align:center;">
        <div id="qrcodeTable" style="margin:0 auto; width:260px;"></div>
    </div>
    <script type="text/javascript">
window.onload = function () {
    var codeValue = "9780199532179";
    codeValue = getUrlParam("code");
    if (codeValue == null || codeValue.length <= 0) { codeValue = "0000000000000" }
    createCode(codeValue);

}
function createCode(codeValue) {
    //生成条码
    JsBarcode("#qrcodeTiaoMa", codeValue, {
        displayValue: false,
        fontSize: 100
    });
    //生成二维码
    jQuery('#qrcodeTable').qrcode({
        render: "table",
        text: codeValue
    });
}
//获取url中的参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
}
    </script>
</body>
</html>

第三步:在窗体打开的时候,加载 Web浏览器 对应的 条码生成h5

 

Dim h5Path,codeValue
h5Path="file:///"&Sys.ProjectDir &"\H5CreateCode\index.html"
codeValue=文本框0.Text
If Len(codeValue)<=0 then
    Exit Sub
End If
h5Path=h5Path&"?code="&codeValue
Web浏览器0.Url=h5Path
Web浏览器0.print()

 第四步:生成按钮的事件代码

Dim h5Path,codeValue
h5Path="file:///"&Sys.ProjectDir &"\H5CreateCode\index.html"
codeValue=文本框0.Text
If Len(codeValue)<=0 then
    MsgBox "请输入要生成的条码内容!"
    Exit Sub
End If
h5Path=h5Path&"?code="&codeValue
Web浏览器0.Url=h5Path
Web浏览器0.print()

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

永远是我的最爱

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值