帝普一世
帝普一世
  • 发布:2015-09-13 18:56
  • 更新:2015-09-15 16:18
  • 阅读:7106

如何实现扫描二维码直接在APP中打开网页

分类:HBuilder

使用了扫描二维码功能,扫描出网址,点击弹出是否打开的提示框,点打开,是使用第三方浏览器打开的。。

怎样实现直接在APP内访问?

2015-09-13 18:56 负责人:无 分享
已邀请:
GCJ

GCJ

识别以后, 根据识别结果进行判断。 最简单的就是,识别出http://开头的, 就打开呗。 参考h5+的示例程序,代码如下:

var scan = new plus.barcode.Barcode('bcid');  
scan.onmarked=onmarked;  
scan.start({conserve:true,filename:"_doc/barcode/"});  
function onmarked(type,result,file){  
    result = result.replace(/\n/g, '');  
    if(type==plus.barcode.QR && result.trim().indexOf('http://')===0) {  //识别到是url,则自动使用外部浏览器打开  
        plus.runtime.openURL(result);  
    }  
}

该问题目前已经被锁定, 无法添加新回复