locked
WebView ScriptNotify from "ms-appdata"

    Question

  • changed the Scenario6 of webview sample  in the following way

    public Scenario6()
    {
        this.InitializeComponent();

        //string src = "ms-appx-web:///html/scriptNotify_example.html";
        string src = "ms-appdata:///local/Oeconomix/OPS/scriptNotify_example.html";

        webViewLabel.Text = string.Format("Webview: {0}", src);
        webView6.Navigate(new Uri(src));
        webView6.ScriptNotify += webView6_ScriptNotify;
    }

          


    void webView6_ScriptNotify(object sender, NotifyEventArgs e)
    {
        Color c=Colors.Red;
        if (e.CallingUri.Scheme =="ms-appx-web" || e.CallingUri.Scheme == "ms-appdata")
        {
            if (e.Value.ToLower() == "blue") c = Colors.Blue;
            else if (e.Value.ToLower() == "green") c = Colors.Green;
        }
        appendLog(string.Format("Response from script at '{0}': '{1}'", e.CallingUri, e.Value), c);
    }

    After the change I don't get the notify event anymore.
    Is it possible to register a local website as allowed uri in the package.appymanifest.file or is there another way to get notifications from a html page stored in a local file.
    Need this to work with downloaded extended ebooks.

    Thursday, July 11, 2013 1:02 PM

Answers

  • Thank you for the feedback. This was a policy decision we made that we have had feedback on so we re-evaluate it. The same restriction doesn't apply if you use NavigateToStreamUri together with a resolver object. Internally that's what happens with ms-appdata:/// anyway.

    The webview sdk sample scenario 4 implements a lot of what you may want in a resolver. The interesting thing for epub scenarios is using this technique you can deliver content straight from the epub file without having to extract it first. This is what we did for the demo in John Hazen's talk at Build.

    • Marked as answer by SVIE Sunday, July 14, 2013 4:57 AM
    Thursday, July 11, 2013 7:57 PM

All replies

  • Thank you for the feedback. This was a policy decision we made that we have had feedback on so we re-evaluate it. The same restriction doesn't apply if you use NavigateToStreamUri together with a resolver object. Internally that's what happens with ms-appdata:/// anyway.

    The webview sdk sample scenario 4 implements a lot of what you may want in a resolver. The interesting thing for epub scenarios is using this technique you can deliver content straight from the epub file without having to extract it first. This is what we did for the demo in John Hazen's talk at Build.

    • Marked as answer by SVIE Sunday, July 14, 2013 4:57 AM
    Thursday, July 11, 2013 7:57 PM
  • Thanks for the hint. I tried the recommended way using a resolver and it works fine.
    Sunday, July 14, 2013 4:57 AM
  • are you ok?? i see the same problem. i can not do.
    Tuesday, September 17, 2013 6:35 AM
  • This is really unfortunate for us. We have planned performance update for our app using the ms-appdata navigation, but because the ScriptNotify does not work from such pages, we need to continue using NavigateToString.

    I just don't understand why it's disabled for such pages and it's even not possible to define in app manifest to enable script notification, just like it's possible for https pages in there?

    Wednesday, September 25, 2013 1:23 PM
  • yes, i am think so.

    but i cannot use NavigateToString, because my web include most js files and image.

    cannot display the image if using NavigateToString. 

    Thursday, September 26, 2013 1:29 AM