locked
ScriptNotfiy never fired

    Question

  • Hi,

    I have a webview with a local http server and I am loading an html file with the following content :

    <!DOCTYPE html>
    <html>
    <head>
        <title>Test</title>
        <script>
            function myFunction() {
                window.external.notify('notified');
                document.getElementById("demo").innerHTML = "Hello World";
            }
        </script>
    </head>
    <body>
        <p>Click the button to trigger a function.</p>
        <button onclick="myFunction()">Click me</button>
        <p id="demo"></p>
    </body>
    </html>
    public WebBasedView()
            {
                this.InitializeComponent();
    
                _objViewModel = new WebBasedViewModel();
                this.DataContext = _objViewModel;
    
                _objViewModel.NavigationHelper = new NavigationHelper(this);
                _objViewModel.NavigationHelper.LoadState += navigationHelper_LoadState;
                _objViewModel.NavigationHelper.SaveState += navigationHelper_SaveState;
    
    
                webView.NavigationCompleted += webView_NavigationCompleted;
                webView.NavigationStarting += webView_NavigationStarting;
                webView.ScriptNotify += webView_ScriptNotify;
            }
    protected async override void OnNavigatedTo(NavigationEventArgs e)
            {
                BookDataItem bdi = (BookDataItem)e.Parameter;
                _objViewModel.Container = bdi.Container;
                if (_objViewModel.Container != null)
                {
                    _objViewModel.Package = bdi.Package;
                    _objViewModel.Package2 = bdi.Package2;
     
                    mServer = new EpubServer(this, _objViewModel.Package, _objViewModel.Package2);
                    await mServer.Start();
    
                    webView.Navigate(new Uri(string.Format("http://127.0.0.1:{0}/{1}", mServer.Port, HTTP_READER_URI)));
                }
    
                _objViewModel.NavigationHelper.OnNavigatedTo(e);
            }

    void webView_ScriptNotify(object sender, NotifyEventArgs e)
            {
                DecodeReadiumNotifications(e.Value);
            }

    However I don't receive the ScriptNotify event.

    Any idea why ?



    • Edited by Vincent Rich Tuesday, February 11, 2014 3:58 PM a
    Tuesday, February 11, 2014 3:51 PM

Answers

All replies