locked
Can't display web application in WebView

    Question

  • Hello,

    I have a problem with display web application in my WebView control.

    if I navigate to any site like "http://google.com" everything work fine, but when I try  navigating to web application I see the empty page. I know this web app uses HTML 5 element, particularly canvas.

    What should I do to display it correctly?

    Code I used (WebView is in form):

    Uri uri=new Uri("some adress");

    webView1.Navigate(uri);

    Tuesday, September 02, 2014 12:22 PM

Answers

  • Hi Alex,

    That is expected, alert() is not supported in Windows Store App WebView. We use MessageDialog class in Windows Store App.

    Let's say if you really need alert something to your user, you could inject following code in your javascript:

    window.alert = function(__msg){window.external.notify(' + __msg + ');};

    And set a ScriptNotify event for webview to catch the msg you passed out, then display the message in MessageDialog class.

    For more information you could ref: http://channel9.msdn.com/Series/Windows-Store-Developer-Solutions/WebView-Magic-Tricks-Series-Part-3-Alert-Interceptor

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Thursday, September 04, 2014 2:04 AM
    Moderator

All replies

  • What do you mean by a web application here?

    Using WebView you could only navigate to site.

    Are you talking about launching the default browser from your app?

    If so you could go with this:

    Opening a URL in the default browser in a Windows 8 desktop application


    Happy Coding!

    Tuesday, September 02, 2014 5:51 PM
  • Web application is simple html, bute opened site lookes like an application.

    I can open this html, which is in external server, in default IE broser, 

    but if I uses WebView in my metro app to open this html, I just see white empty screen.

    What can it be?

    Wednesday, September 03, 2014 5:15 AM
  • Using cut and try method I find, that webView does not support js performance in html. I can invoke any js method in code, but in HTML js code does not perform.

    Can anyone help me?

    Wednesday, September 03, 2014 8:18 AM
  • Hi Alex,

    If your web application is simply a HTML page, then should be no problem, but note there are few HTML5 features are not supported in Windows Store App Webview: WebView does not currently support some HTML5 features including AppCache, IndexedDB, programmatic access to the Clipboard, or geolocation.

    But what do you mean by in HTML, js code does not perform. See this might help you: How to invoke Javascript inside the displayed webpage of a Webview.

    Could you provide more information or simply share us a demo?

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, September 03, 2014 12:40 PM
    Moderator
  • Thanks for your answer, Jamles.

    As for js code not performing, I mean following: there is a HTML document on external server:

    <!doctype html> 
    <html>
      <head id = 'head'>
        <title>NetGisViewer</title>
        <script type='text/javascript'>
            alert('test');
        </script>
       </head>
       <body id = 'body'>
    <img src="http://im0-tub-ru.yandex.net/i?id=c3556bedab3d39d686e4cbb63b9e3534-07-144&n=21" alt="pict" />
       </body>
    </html>

    When I navigate to this document in webView I want to see a picture and get the message "test" in alert. But in fact I can see only a picture.

    I can't understand, why I did not see an alert message?

    Wednesday, September 03, 2014 1:38 PM
  • Hi Alex,

    That is expected, alert() is not supported in Windows Store App WebView. We use MessageDialog class in Windows Store App.

    Let's say if you really need alert something to your user, you could inject following code in your javascript:

    window.alert = function(__msg){window.external.notify(' + __msg + ');};

    And set a ScriptNotify event for webview to catch the msg you passed out, then display the message in MessageDialog class.

    For more information you could ref: http://channel9.msdn.com/Series/Windows-Store-Developer-Solutions/WebView-Magic-Tricks-Series-Part-3-Alert-Interceptor

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Thursday, September 04, 2014 2:04 AM
    Moderator