2013-02-27 70 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 
});