2013-02-27 67 views
1

我工作在Titanium Mobile。我的问题是:在Webview中更改链接行为

Can I change the behavior of the link present in the webview??? 

即假设我有一个文本:我的名字是布尔汉。在这篇文章中Burhan是一个链接。所以我需要当我点击布尔汉它应该打开一个窗口,我在其中放置我的标签等。是否有可能?

PS:我想要的解决方案只是点击链接,而不是点击webview .. PS:我如何跟踪webview中的链接被点击..? (我只需要这个)

任何帮助? 在此先感谢。

+0

其悲伤无济于事然而:( – 2013-02-27 08:15:55

+0

参阅此http:/ /stackoverflow.com/questions/14856448/add-event-listener-to-links-loaded-in-webview-titanium-mobile/14872695#14872695 – 2013-02-27 09:37:47

回答

2

最简单的解决方案是使用Ti.App EventListeners。

在网页视图,你需要提供一个标签像

<span onclick="Ti.App.fireEvent('url', {information: 'thatcanbeuseful', like: 'anUrl'});">Your Name</span> 

然后,你需要提供一个全球性的事件监听器:

Ti.App.addEventListener('url', function(e){ 
    // open a window or someting or open an URL with: 
    Ti.Platform.openURL(e.anUrl); // from passed object 
});