Please, tell us how to recreate the issue in as much detail as possible.
Background of the implementation: App downloads the web content locally in the app. This web content is loaded in the Webview. There is a communication between the web content loaded and the NativeScript which we are trying to achieve through this plugin. The web content downloaded has inline weblinks (anchor tag href values) which we want to open in external browser using util.openUrl(). But at the same time "onunload" and "onbeforeunload" methods of the webpage are getting called before "shouldOverrideUrlLoadingEvent" called.
We need a solution to make sure that onbeforeunload or onunload events of the webpage are not fired when user clicks the inline links on that webpage.
Is there any code involved?
Here is the implementation of "shouldOverrideUrlLoadingEvent"
this.webViewInterface.on(WebViewExt.shouldOverrideUrlLoadingEvent, (args: ShouldOverrideUrlLoadEventData) => {
var pattern = /^((http|https|ftp):\/\/)/;
var filepattern = /^((file):\/\/)/;
if (filepattern.test(args.url)) {
args.cancel = false;
}
if(pattern.test(args.url)) {
args.cancel = true;
util.openUrl(args.url);
}
});
I don't think this isn't something we can control.
We just capture events from the WebView and I see no way to control when these events are triggered inside the WebView.
Which platform(s) does your issue occur on?
Please, provide the following version numbers that your issue occurs with:
tns --version
to fetch it) 5.4.2node --version
to fetch it) v10.16.0npm ls tns-core-modules
in your project to fetch it.) ^5.4.2"tns-android"
and"tns-ios"
properties in thepackage.json
file of your project) 5.4.0package.json
file of your project and paste your dependencies and devDependencies here) "dependencies": { "@angular/animations": "~7.1.0", "@angular/common": "~7.1.0", "@angular/compiler": "~7.1.0", "@angular/core": "~7.1.0", "@angular/forms": "~7.1.0", "@angular/http": "~7.1.0", "@angular/platform-browser": "~7.1.0", "@angular/platform-browser-dynamic": "~7.1.0", "@angular/router": "~7.1.0", "@nota/nativescript-webview-ext": "^5.4.1", "angular-custom-tour": "0.0.17", "base-64": "^0.1.0", "nativescript-angular": "next", "nativescript-app-tour": "^0.10.0", "nativescript-appversion": "^1.4.1", "nativescript-downloader": "^2.1.0", "nativescript-drop-down": "^4.0.1", "nativescript-feedback": "^1.2.0", "nativescript-orientation": "^2.2.1", "nativescript-pdf-view": "^2.0.1", "nativescript-plugin-firebase": "^9.0.1", "nativescript-social-login": "^4.0.1", "nativescript-social-share": "^1.4.0", "nativescript-sqlite": "^2.2.1", "nativescript-theme-core": "~1.0.4", "nativescript-ui-gauge": "^3.7.1", "nativescript-ui-listview": "^3.6.0", "nativescript-ui-sidedrawer": "^4.3.0", "nativescript-webview-interface": "^1.4.2", "nativescript-xml2js": "^0.5.2", "nativescript-zip": "^3.0.0", "reflect-metadata": "~0.1.8", "rxjs": "~6.3.3", "rxjs-compat": "^6.3.3", "tns-core-modules": "^5.4.2", "tns-platform-declarations": "^5.4.2", "typescript": "^3.5.2", "url": "^0.11.0", "zone.js": "~0.8.26" }, "devDependencies": { "@angular/compiler-cli": "^7.2.7", "@nativescript/schematics": "~0.4.0", "@ngtools/webpack": "~7.1.0", "nativescript-dev-sass": "~1.6.0", "nativescript-dev-typescript": "next", "nativescript-dev-webpack": "^0.24.1" }Please, tell us how to recreate the issue in as much detail as possible.
Background of the implementation: App downloads the web content locally in the app. This web content is loaded in the Webview. There is a communication between the web content loaded and the NativeScript which we are trying to achieve through this plugin. The web content downloaded has inline weblinks (anchor tag href values) which we want to open in external browser using util.openUrl(). But at the same time "onunload" and "onbeforeunload" methods of the webpage are getting called before "shouldOverrideUrlLoadingEvent" called.
We need a solution to make sure that onbeforeunload or onunload events of the webpage are not fired when user clicks the inline links on that webpage.
Is there any code involved?
Here is the implementation of "shouldOverrideUrlLoadingEvent"
this.webViewInterface.on(WebViewExt.shouldOverrideUrlLoadingEvent, (args: ShouldOverrideUrlLoadEventData) => {
var pattern = /^((http|https|ftp):\/\/)/; var filepattern = /^((file):\/\/)/; if (filepattern.test(args.url)) { args.cancel = false; } if(pattern.test(args.url)) { args.cancel = true; util.openUrl(args.url); } });