0

在钛中,我使用 webview 来显示一个已经为移动浏览器格式化的 wordpress 博客页面。而不是编写我自己的界面,这是一个很好的解决方法。应用程序唯一关注的不是浏览器。

但我的问题在于,当用户单击初始显示域之外的链接时。我只希望主域显示在应用程序浏览器中。如果单击任何其他链接,将用户带到该域之外,我希望在手机默认浏览器中打开它。

谁能指出我的方向。我尝试添加一个侦听器来尝试捕获链接点击,但是,我没有成功。

谢谢

4

2 回答 2

1

这篇博文中,我展示了如何在网页中查找链接并更改链接行为。使用相同的方法,您可以拦截链接并重定向到在设备默认浏览器中打开 URL

于 2011-01-31T15:07:28.133 回答
0

One solution would be to catch the onclick() Event by Javascript inside the WebView (your blog code) and handle this by a custom handler. Maybe you can inject the javascript event handler code into the running WebView through Titanium.

Another solution is to make your blogposts readable for app technology and create a new data interface. This is the way I would do. For that I would use some kind of JSON data format and a simple REST Interface to get the data.

I don't think bove solutions are that simple. If you want an app with "great feeling", you'll have to handle the events by your own. Maybe Phonegap would be a better solution four your problem. But there you will still need a kind of REST/JSON interface for your blog data. The idea behind an app is, that the main code is in your app and you get the content from a remote source. This way you'll get an advantage compared to a simple browser optimized site.

于 2011-01-27T20:55:52.670 回答