简体   繁体   English

Windows Phone Web浏览器控件为空?

[英]Windows phone webbrowser Control is Blank?

Im trying to open a URL(Some link) in Webbrowser Control. 我正在尝试在Webbrowser控件中打开URL(某些链接)。 The link return a html page which contain Google Graph , but my Webbrowser Control is Blank and dont display any thing on it. 该链接返回一个包含Google Graph的html页面,但是我的Webbrowser控件为空白,并且不显示任何内容。 It works fine on WebBrowserTask and on my pc so their is no problem in this link but it is blank on webBrowser Control Any Idea How i can Do this ?? 它在WebBrowserTask和我的PC上运行良好,因此在此链接中它们没有问题,但在webBrowser控件上为空。任何想法我该怎么做?

 public GraphPage()
     {
         InitializeComponent();
         webBrowser1.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(Browser_Navigated);
         webBrowser1.Navigating += new EventHandler<NavigatingEventArgs>(Browser_Navigating);

         loadPage(getBaseUrl(graphType));
      }

 private  void loadPage(String url )
      {
           webBrowser1.IsScriptEnabled = true;
           webBrowser1.Source = new Uri("Link");
      }

As mentioned by user112553, set IsScriptEnabled true. 如user112553所述,将IsScriptEnabled设置为true。 Can be done under the XAML-code or in the code-behind with 可以在XAML代码下或在后面的代码中完成

XAML XAML

<phone:WebBrowser x:Name="Browser" IsScriptEnabled="True" />

Code-Behind 代码隐藏

Browser.IsScriptEnabled = true;

I encountered a similar situation, with Windows Phone 8 and a HTML page using JQuery. 我在Windows Phone 8和使用JQuery的HTML页面中遇到了类似情况。

IsScriptEnabled=true wasn't enough (the page didn't render properly). IsScriptEnabled=true还不够(页面无法正确呈现)。 I solved adding to the html page a doctype declaration: 我解决了将doctype声明添加到html页面:

<!DOCTYPE html>
<html>
...

Seems like the WebBrowser component refuses to render HTML5 pages without explicit defining the document-type. 似乎WebBrowser组件拒绝呈现HTML5页面而不显式定义文档类型。

Since it's a common problem with rendering pages in IE<11 when not defining this tag, the cause of why my scripts didn't run could be many and most likely a reference to a HTML5 tag which was not handled correctly. 由于在未定义此标记时在IE <11中呈现页面是一个常见问题,因此我的脚本无法运行的原因可能很多,而且很可能是对HTML5标记的引用未正确处理。

ref: http://msdn.microsoft.com/en-us/hh779632.aspx 参考: http : //msdn.microsoft.com/en-us/hh779632.aspx

Since windows phone 8.0 is based on Internet Explorer 10, it makes sense, the confusing part with debugging this behavior is that Internet Explorer on your phone renders the page perfectly. 由于Windows Phone 8.0是基于Internet Explorer 10的,因此这很有意义,调试此行为的令人困惑的部分是您电话上的Internet Explorer可以完美呈现页面。 Still the WebBrowser component will not. WebBrowser组件仍然不会。

If this is documented in the API specifications, it should be easier to find, because I was not able to find any information that would point me to this solution at all, this would be mostly because my pages was rendered in WebViews for Android and IOS without any problems. 如果在API规范中对此进行了说明,则应该更容易找到,因为我根本找不到任何指向该解决方案的信息,这主要是因为我的页面是在Android和IOS的WebViews中呈现的没有任何问题。

Thanks to Antonio Pelleriti for providing this solution. 感谢Antonio Pelleriti提供此解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM