0

I want to redirect user from webview to my metro application? , I have the facility to change webview html content (aspx)

naCheex
  • 1,131
  • 3
  • 14
  • 34
  • If U want redirect Using URL, unfortunately not possible. [http://blogs.msdn.com/b/wsdevsol/archive/2012/10/18/nine-things-you-need-to-know-about-webview.aspx#AN9 ] – Kumar Oct 12 '13 at 08:26
  • I think you couldn't get my point , I am using webview in metro app and there we provide some template editor facility to user , so the problem is when user would finish his editing then he has to move next page of app. How we solve this problem? – naCheex Oct 13 '13 at 20:07
  • Are we talking about same Metro App? Do you just want to navigate to another page inside your current app? – n00b Oct 14 '13 at 09:19
  • Yes @Braim we are talking about metro app, and I want to navigate another page from webview. – naCheex Oct 14 '13 at 12:33

2 Answers2

1

If you can redirect the user to a 'fake url' of your choice (such as http://www.finished.com) when they are finished editing, then you would just need to listen to the LoadCompleted event of the WebView. In this event handler you can check the url to see if it matches your 'fake url' and if it does, then cancel the navigation and navigate to your xaml page.

    void webView_LoadCompleted(object sender, NavigationEventArgs e)
    {
        if (e.Uri.AbsoluteUri.Contains("finished.html"))
        {
            this.Frame.Navigate(typeof(MainPage));
        }
    }
Jon
  • 2,891
  • 2
  • 17
  • 15
  • I think you also couldn't get my point. I want to redirect from webview (such as e.g [www.myEditor.com]) to my metro app page main.xaml . Note: I can edit site [www.myEditor.com] so if we have any oppertunity to put something in html content to redirect so we can do it. – naCheex Oct 15 '13 at 08:14
  • I think what I described above will work for you, this is how I do it. Change your html to redirect to "http://www.finished.com" when you want to switch back to metro app page. Then in WebView.NavigationStarting event, check the url and if it is "http://www.finished.com", then switch to metro page. – Jon Oct 15 '13 at 16:20
  • great (y) I got your point but couldn't successful yet , can you send me the example or blog's link? – naCheex Oct 16 '13 at 14:13
  • Correction: You need to use the NavigationFailed event (only windows phone has the NavigationStarting event). I edited the answer above to show this. – Jon Oct 16 '13 at 16:36
  • need your help I have html page which is hosted here: [http://lcpscc.site50.net/win8/test.html] this page only anchor tag which redirect it to google like this: `Google` And Xaml code is here : ` ` And .cs code here: `void navigateToApp(object sender, WebViewNavigationFailedEventArgs e) { if (e.Uri.AbsoluteUri.Contains("https://www.google.com")) { this.Frame.Navigate(typeof(test.Pages.main)); } }` is something wrong? – naCheex Oct 18 '13 at 11:43
  • I was wrong, for WebView you need to use the 'LoadCompleted' event not the NavigationFailed event. – Jon Oct 18 '13 at 16:19
0

What you want is having your Metro app handle a custom protocol like myprotocl://... then have a link in your WebView to that protocol. That will open your metro app. see articles below Registering a protocol handler in Windows 8

and this one

http://www.itsjustwhatever.com/2012/10/28/launch-windows-8-metro-apps-from-a-desktop-shortcut-or-command-line/

you see how for example ebay:// is opening ebay app

Community
  • 1
  • 1
n00b
  • 1,832
  • 14
  • 25
  • , I am using webview in metro app and there we provide some template editor facility to user , so the problem is when user would finish his editing then he has to move next page of app. How we solve this problem? – naCheex Oct 14 '13 at 15:46