Last active
December 22, 2015 00:09
-
-
Save ajeetpratap/6387095 to your computer and use it in GitHub Desktop.
clikable link using html and javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Ti.UI.createWindow({}); | |
var vidWin = Titanium.UI.createWindow({ | |
title : 'click link', | |
backgroundColor : '#fff', | |
navBarHidden:false | |
}); | |
var nav = Ti.UI.iPhone.createNavigationGroup({window:vidWin}); | |
var _comment = [ | |
"A nine-patch (9-patch) image is simply a standard png image with a transparent border of a single pixel, containing guides defined by solid black (#000) color fills.", | |
" the draw9patch utility provided in the Android SDK tools directory is recommended for this purpose.", | |
"The nine-patch technique may be used with any of Titanium's static image properties. See the Button with Nine-patch Background Image example for a demonstration.", | |
"Note that images are referenced in the code without the .9 part of the filename, and that the project should be cleaned to ensure that the files are correctly copied to the project." | |
]; | |
var inReply = ["james","monica","gamer","troll"]; | |
var user = ["Alex","Smith","Monica","James"]; | |
var _rowData = []; | |
for(var i=0;i<4;i++) | |
{ | |
var row = "<tr><td><p><span style='color: #ff0000 ; font-size:15px'><b>"+user[i]+"<b></span><span style='color: #00000 ; font-size:12px'>"+_comment[i]+"</span><span style='font-size:12px'><a href=\'javascript:void(0)\' onClick=\"javascript:link_hit(\'"+inReply[i]+"\');\" style='text-decoration:none'>@"+inReply[i]+"</a></span></p></td></tr>"; | |
_rowData.push(row); | |
} | |
var _html ="<html><body><script type=\"text/JavaScript\">function link_hit(str){ Ti.App.fireEvent(\'openWin\',{msg:str});}</script><table border='1' cellspacing=0 >"; | |
for(var i=0;i<4;i++) | |
{ | |
_html = _html +_rowData[i]; | |
} | |
_html = _html +"</table></body></html>"; | |
var web = Ti.UI.createWebView({ | |
borderColor:'#000', | |
borderWidth:2, | |
width:'90%', | |
height:Ti.UI.SIZE, | |
html:_html | |
}); | |
vidWin.add(web); | |
web.addEventListener('touchmove',function(e) { | |
//e.preventDefault(); | |
}); | |
win.add(nav); | |
win.open(); | |
var text = "A nine-patch (9-patch) image @ola is simply a standard png image with a @roger transparent border of a single pixel, containing guides defined by solid black (#000) color fills."; | |
var reg = new RegExp(/@\b[\w]*/gi); | |
var result; | |
//simple regex to check whether the text start with "@" | |
while ((result = reg.exec(text)) !== null) | |
{ | |
Ti.API.info('info '+result); | |
} | |
Ti.App.addEventListener('openWin',function(e){ | |
var _win = require('/newWin'); | |
var win = new _win(e.msg); | |
nav.open(win); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment