2014-05-22 168 views
1

我有一个WP8 Cordova应用程序,它在本地有一个页面,然后重定向到服务器以获得更多功能。这两个页面都有cordova JS API可用,并且工作正常。如何重新启动科尔多瓦WP8应用程序?

除了当我想再次去本地开始页面。它的任何锚点(指向x-wmapp0:www/index.html)都不适用于HTML端。

此外,任何插件和调用CordovaBrowser.Navigate()的技巧都会导致UnauthorizedAccessException错误。

回退一直是我去尝试回到浏览器的历史是这样的:

window.history.go(-window.history.length + 1); 

但是,如果我花时间在远程页面在这一切没有做任何事情。所以这也不适用!

是否有体面的方式到达首页?在C#或其他方面的帮助下?

回答

0

所以UnauthorizedAccessException东西来自线程问题。 (对于WP的VS Express有时可以很好地隐藏异常的细节。)

这是一个完整的插件,可用neatest优雅进行重定向。

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows; 

using WPCordovaClassLib.Cordova; 
using WPCordovaClassLib.Cordova.Commands; 

namespace Cordova.Extension.Commands 
{ 
    public class Jumper : BaseCommand 
    { 
     /** Instruct the browser component to go to beginning. */ 
     public void goHome(string unused) 
     { 
      Deployment.Current.Dispatcher.BeginInvoke(() => 
      { 
       var webview = WebViewHandler.getInstance().webView; 
       webview.CordovaBrowser.Navigate(webview.StartPageUri); 
      }); 
     } 
    } 
} 

WebViewHandler是共享科尔多瓦的WebView到插件,在another SO answer描述的单(感谢@MikeBryant!)。

+0

有趣的是,这种方法具有类似于'history.go()'方法的冻结特性。 IEMobile在页面之间做什么? – progo

相关问题