改变Webview中的链接行为

Change link behavior in Webview

本文关键字:链接 Webview 改变      更新时间:2023-09-26

我在Titanium Mobile工作。我的问题是:

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

。假设我有一条短信:我叫伯汉。在这篇文章中,伯汉是一个链接。所以我需要当我点击Burhan时,它应该打开一个窗口,我在其中放置我的标签等。这可能吗?

PS:我想解决方案只是点击链接,而不是点击webview..PS:我怎么能跟踪链接在webview点击..??? (我只需要这个)

有什么帮助吗?提前感谢。

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

在你的WebView中你需要提供一个像 这样的标签
<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
});