Mashhood Adeeb
Mashhood Adeeb

Reputation: 37

Windows phone webbrowser Control is Blank?

Im trying to open a URL(Some link) in Webbrowser Control. The link return a html page which contain Google Graph , but my Webbrowser Control is Blank and dont display any thing on it. 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 ??

 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");
      }

Upvotes: 0

Views: 977

Answers (3)

chezuma
chezuma

Reputation: 1

Seems like the WebBrowser component refuses to render HTML5 pages without explicit defining the document-type.

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.

ref: 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. Still the WebBrowser component will not.

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.

Thanks to Antonio Pelleriti for providing this solution.

Upvotes: 0

Antonio Pelleriti
Antonio Pelleriti

Reputation: 853

I encountered a similar situation, with Windows Phone 8 and a HTML page using JQuery.

IsScriptEnabled=true wasn't enough (the page didn't render properly). I solved adding to the html page a doctype declaration:

<!DOCTYPE html>
<html>
...

Upvotes: 0

kadir
kadir

Reputation: 1417

As mentioned by user112553, set IsScriptEnabled true. Can be done under the XAML-code or in the code-behind with

XAML

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

Code-Behind

Browser.IsScriptEnabled = true;

Upvotes: 1

Related Questions