Ios Tianium:如何在webview中从外部URL重定向到内部URL

Ios Tianium:如何在webview中从外部URL重定向到内部URL,ios,redirect,webview,titanium,appcelerator,Ios,Redirect,Webview,Titanium,Appcelerator,所以我知道如何在Tianium Webview中访问外部和内部URL。但我不知道如何从外部url重定向到内部url 我在根文件夹中有一个名为“index.html”的文件,因此对于webview来说,应该可以访问它: Ti.UI.createWebView({ url: 'index.html' }); 外部URL非常直接 Ti.UI.createWebView({ url: 'http://www.google.com' }); 但是,在外部url上,如何重定向到此本地文件

所以我知道如何在Tianium Webview中访问外部和内部URL。但我不知道如何从外部url重定向到内部url

我在根文件夹中有一个名为“index.html”的文件,因此对于webview来说,应该可以访问它:

Ti.UI.createWebView({
    url: 'index.html'
});
外部URL非常直接

Ti.UI.createWebView({
    url: 'http://www.google.com'
});
但是,在外部url上,如何重定向到此本地文件?这些都不起作用:

 <a href="file://index.html">LOCAL?</a>
 <a href="file:///index.html">LOCAL?</a>

关于如何做到这一点,有什么线索吗?

最后,我发现了实现这一点的两种可能性。但这不能通过重定向来完成

一:使用
webview.evalJS()
函数轮询某个变量

var my_data = $.login_webview.evalJS('global.data;');
当然,它只适用于字符串,而不适用于对象。因此,如果要传递JSON,请确保将其设置为字符串

第二:在服务器端执行实际重定向,转到另一个服务器端页面并监视URL更改,然后再次执行
evalJS()
,但不需要轮询

$.login_webview.addEventListener('load',function(e){
if (e.url.indexOf('mobile/redirect.php') > -1){
    var my_data = $.login_webview.evalJS('global.data');
    }
 });

只要使用2确保您使用服务器端技术在Javascript中实际设置了所需的数据。

只是想知道如果webView.evalJS('someFunctionToPrintout(window.location);');当webView打开local file index.html时,这会为您提供本地文件的正确路径吗?我将获得文件的完整路径,
file://Users/username/[..]/index.html
$.login_webview.addEventListener('load',function(e){
if (e.url.indexOf('mobile/redirect.php') > -1){
    var my_data = $.login_webview.evalJS('global.data');
    }
 });