What is the correct way to watch URL changed on webview

I’m using 0.21 version.

The code above says that UrlChanged data type does not exist.

<WebView ux:Name="webView" Url="{url}" Opacity="1">
        <PageLoaded>
            <EvaluateJS Handler="{onPageLoaded}">
                var result = {
                    url : document.location.href
                };

                debug_log(document.location.href);
                return result;
            </EvaluateJS>
        </PageLoaded>

        <UrlChanged Handler="{onUrlChanged}">
            var result = {
                url : document.location.href
            };

            debug_log(document.location.href);
            return result;
        </UrlChanged>
    </WebView>

UrlChanged is an event on WebView, so you’d use it like this <WebView UrlChanged="{myEventHandlerInJS}"/>

I guess the confusion above is because PageLoaded is the name of both an event on WebView and a trigger that works with WebView. However, in the case of UrlChanged there is no such trigger as far as I know. :slight_smile:

Hi Remi Pedersen,

Before I post this issue, i have tested UrlChanged as you mentioned. But this just has no effect at all no callback is fired.

and using PageLoaded + EvaluateJS either.

I upgrade to 0.21 and i was using the facebook login example from here:

https://github.com/fusetools/fuse-samples

This works on Android, built with Fuse 0.21

<App>
    <JavaScript>
        var Observable = require("FuseJS/Observable");
        url = Observable("http://www.google.com");
        function uc(){
            console.log(url.value);
        }
        module.exports = { uc: uc, url: url };
    </JavaScript>
    <ClientPanel>
        <NativeViewHost>
            <WebView Url="{url}" UrlChanged="{uc}"/>
        </NativeViewHost>
    </ClientPanel>
</App>

Tested on iOS v 9.3 and nothing happend, on device and simulator. Just copy and paste our code.

I just got around to testing and you are indeed right. Raising an internal ticket to get this fixed.

Hi Raphael, Can you check whether this is fixed with the latest Fuse version (0.23)?

Yes Remi, I’ll check this today.

Remi, yeah… it’s working. Thanks.

Great! :slight_smile: