`
Mr.Joe
  • 浏览: 138117 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

sencha touch使用正则法处理文字中网址

阅读更多

//定义包含网址的字符串
var currentContent = "asdf空间啊;SD卡附件阿克苏的房间;http://www.baidu.com/ 阿克江送达方;可垃圾是否";
//利用正则发处理后点击可打开网页,下面是两种不同打开方式
//调用设备浏览器打开
str = currentContent.replace(/(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|\&|-)+)/g, '<a style="color:blue" onclick="window.open(\'$1$2\', \'_system\')" href="#">$1$2</a>');
//使用应用内Webview打开
str = currentContent.replace(/(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|\&|-)+)/g, '<a style="color:blue" onclick="window.open(\'$1$2\', \'_blank\', \'location=no\')" href="#">$1$2</a>');
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics