【问题标题】:Windows Phone 8 Web Browser control not workingWindows Phone 8 Web 浏览器控件不起作用
【发布时间】:2013-03-06 21:06:50
【问题描述】:

我正在尝试导航到 URL,但 Web 浏览器控件显示空白页或显示找不到页面错误。这是我的代码:

Private Sub qwb_Loaded(sender As Object, e As RoutedEventArgs) Handles qwb.Loaded
    NavigationContext.QueryString.TryGetValue("url", url)
    Dim urltonav = New Uri(url, UriKind.RelativeOrAbsolute)
    qwb.Navigate(urltonav)
End Sub

PS:网址是http://www.mobile.quora.com。在 Page1_Loaded 事件下加载页面也不起作用。

这是具有 Web 浏览器控件的页面的 XAML 代码:

<phone:PhoneApplicationPage
    x:Class="MyApp.Page1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">

       <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

               <StackPanel Grid.Row="0" Margin="12,17,0,28"/>
        <phone:WebBrowser x:Name="qwb" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.RowSpan="2" Height="768" Width="480" IsScriptEnabled="True"/>

         </Grid>

</phone:PhoneApplicationPage>

我正在尝试在设备上运行该应用程序,而不是在具有工作 WiFi 的模拟器上运行。操作系统版本是 Windows Phone 8,我有 Visual Studio 2012。我认为网络没有问题。我什至尝试使用 .Source 属性而不是 Navigate 但它也不起作用。

【问题讨论】:

  • 该 URL 在桌面和 WP8 设备上的 IE 上都失败(找不到 404)。为什么你希望它在代码中工作?

标签: vb.net xaml windows-phone-8 webbrowser-control windows-phone


【解决方案1】:

您可能打算访问http://mobile.quora.com(不带 www)

【讨论】:

  • 谢谢,解决了这个问题。但是我在 Web 浏览器控件中收到“我们在验证安全证书时遇到问题”错误。如何抑制/忽略或禁用它?
【解决方案2】:

你能显示你的网址吗?

  • 如果是 html 页面,则应将其保存在解决方案的文件夹中并写入

    WebBrowser1.Navigate(new Uri("ch51130.html", UriKind.Relative));

  • 如果是简单的网址,比如 www.google.com,那么

    Uri uri = new Uri("http://www.google.co.in");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    相关资源
    最近更新 更多