How to use the @nota/nativescript-webview-ext.WebViewExt.shouldOverrideUrlLoadingEvent function in @nota/nativescript-webview-ext

To help you get started, we’ve selected a few @nota/nativescript-webview-ext examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Notalib / nativescript-webview-ext / demo / app / main-page.ts View on Github external
export function webviewLoaded(args: LoadEventData) {
    webview = args.object;

    if (isAndroid) {
        webview.src = "http://10.0.2.2:8080";
    } else {
        webview.src = "http://localhost:8080";
    }

    webview.on(WebViewExt.shouldOverrideUrlLoadingEvent, (args: ShouldOverrideUrlLoadEventData) => {
        console.log(args.url);
        console.log(args.httpMethod);
        if (args.url.indexOf("google.com") !== -1) {
            args.cancel = true;
        }
    });

    webview.on(WebViewExt.loadFinishedEvent, (args: LoadFinishedEventData) => {
        console.log(`WebViewExt.loadFinishedEvent: ${args.url}`);
        webview.loadStyleSheetFile("local-stylesheet.css", "~/assets/test-data/css/local-stylesheet.css", false);
    });

    webview.on("gotMessage", (msg) => {
        gotMessageData = msg.data;
        console.log(`webview.gotMessage: ${JSON.stringify(msg.data)} (${typeof msg})`);
    });

@nota/nativescript-webview-ext

Extended WebView for NativeScript which adds 'x-local' scheme for local-files. events between WebView and native-layer, javascript execution, injecting CSS and JS-files.

Apache-2.0
Latest version published 2 years ago

Package Health Score

54 / 100
Full package analysis