want to open Link in external browser of WP7

前端 未结 3 1586
感动是毒
感动是毒 2020-12-20 17:54

The architecture is like:
On click of a button an HTML page opens which contains a link in it. On clicking the links I want to open it in external (default) browser of W

相关标签:
3条回答
  • 2020-12-20 18:07

    Normally, you would do so using Target property on <a> tag. But, in WP7 (at least in Emulator), this does not work.

    What you could do is intercept using Navigating event something like following:

    void WebBrowser1_Navigating(object sender, NavigatingEventArgs e)
    {
        if (IsSupposedToOpenInPhoneBrowser(e.Uri))
        {
            e.Cancel = true;
            WebBrowserTask task = new WebBrowserTask();
            task.URL = e.Uri.ToString();
            task.Show();
        }
    }
    
    0 讨论(0)
  • 2020-12-20 18:24

    You can use something like that

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        WebBrowserTask webBrowserTask = new WebBrowserTask();
        webBrowserTask.Uri = new Uri("http://www.someUrl.com");
        webBrowserTask.Show(); 
    }
    
    0 讨论(0)
  • 2020-12-20 18:30

    You can use the WebBrowserTask to launch the browser.

    I've found that you need to escape the URL you pass to it though :(

    0 讨论(0)
提交回复
热议问题