Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
Cordova 6.1.0
Description
Building a cordova app using Ionic.
Loading a URL in webview using inappbrowser plugin but none of the events like loadstart, loadstop get fired.
This is my app.js
var ref = cordova.InAppBrowser.open('http://www.google.com','_self', 'location=no') ref.addEventListener('loadstart', function (event) { console.log('loadstart fired'); }, false); ref.addEventListener('loadstop', function (event) { console.log('loadstop fired'); }, false); ref.addEventListener('loaderror', function (event) { console.log('loadstop fired'); }, false); ref.addEventListener('exit', function (event) { console.log('exit fired'); }, false);
CSP in index.html
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
Console output is blank when _self is used
Note: The events fire when target _blank is used.
I/chromium( 2222): [INFO:CONSOLE(69)] "loadstart fired", source: file:///android_asset/www/src/app.js (69) I/chromium( 2222): [INFO:CONSOLE(73)] "loadstop fired", source: file:///android_asset/www/src/app.js (73) I/chromium( 2222): [INFO:CONSOLE(73)] "loadstop fired", source: file:///android_asset/www/src/app.js (73) I/chromium( 2722): [INFO:library_loader_hooks.cc(130)] Chromium logging enabled: level = 0, default verbosity = 0 I/chromium( 2222): [INFO:CONSOLE(73)] "loadstop fired", source: file:///android_asset/www/src/app.js (73)
Attachments
Issue Links
- is cloned by
-
CB-9497 addEventListener and _system
- Closed
- links to
event listeners shouldn't work if you use _self.
When you use _self you are loading the website inside the cordova webview, not the inAppBrowser webview, and then you are replacing all your existing code with the code from the website you load, so when your page finish loading, your code is gone and won't be executed.
We should document that events only work when using _blank
Are you the one who asked this?
http://stackoverflow.com/questions/36038076/execute-script-in-cordova-webview/