cordova-plugin-inappbrowser
Advanced tools
Comparing version 5.0.0 to 6.0.0
{ | ||
"name": "cordova-plugin-inappbrowser", | ||
"version": "5.0.0", | ||
"version": "6.0.0", | ||
"description": "Cordova InAppBrowser Plugin", | ||
@@ -11,5 +11,3 @@ "types": "./types/index.d.ts", | ||
"browser", | ||
"ios", | ||
"osx", | ||
"windows" | ||
"ios" | ||
] | ||
@@ -28,5 +26,3 @@ }, | ||
"cordova-browser", | ||
"cordova-ios", | ||
"cordova-osx", | ||
"cordova-windows" | ||
"cordova-ios" | ||
], | ||
@@ -52,2 +48,7 @@ "scripts": { | ||
"6.0.0": { | ||
"cordova-android": ">=10.0.0", | ||
"cordova-ios": ">=6.0.0", | ||
"cordova": ">=9.0.0" | ||
}, | ||
"7.0.0": { | ||
"cordova": ">100" | ||
@@ -60,4 +61,4 @@ } | ||
"devDependencies": { | ||
"@cordova/eslint-config": "^3.0.0" | ||
"@cordova/eslint-config": "^5.0.0" | ||
} | ||
} |
108
README.md
@@ -24,8 +24,7 @@ --- | ||
|AppVeyor|Travis CI| | ||
|:-:|:-:| | ||
|[![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-inappbrowser?branch=master)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-inappbrowser)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-inappbrowser.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-inappbrowser)| | ||
# cordova-plugin-inappbrowser | ||
[![Android Testsuite](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/android.yml/badge.svg)](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/android.yml) [![Chrome Testsuite](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/chrome.yml/badge.svg)](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/chrome.yml) [![iOS Testsuite](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/ios.yml/badge.svg)](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/ios.yml) [![Lint Test](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/lint.yml/badge.svg)](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/lint.yml) | ||
You can show helpful articles, videos, and web resources inside of your app. Users can view web pages without leaving your app. | ||
@@ -37,3 +36,3 @@ | ||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); | ||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes'); | ||
@@ -77,3 +76,3 @@ ### `window.open` | ||
- <b>InAppBrowserStatusBarStyle [iOS only]</b>: (string, options 'lightcontent', 'darkcontent' or 'default'. Defaults to 'default') set text color style for iOS. 'lightcontent' is intended for use on dark backgrounds. 'darkcontent' is only available since iOS 13 and intended for use on light backgrounds. | ||
``` | ||
```xml | ||
<preference name="InAppBrowserStatusBarStyle" value="lightcontent" /> | ||
@@ -156,9 +155,3 @@ ``` | ||
Windows supports these additional options: | ||
- __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. | ||
- __hardwareback__: works the same way as on Android platform. | ||
- __fullscreen__: set to `yes` to create the browser control without a border around it. Please note that if __location=no__ is also specified, there will be no control presented to user to close IAB window. | ||
### Supported Platforms | ||
@@ -169,8 +162,6 @@ | ||
- iOS | ||
- OSX | ||
- Windows | ||
### Example | ||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); | ||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes'); | ||
var ref2 = cordova.InAppBrowser.open(encodeURI('http://ja.m.wikipedia.org/wiki/ハングル'), '_blank', 'location=yes'); | ||
@@ -230,2 +221,3 @@ | ||
- __message__: event fires when the `InAppBrowser` receives a message posted from the page loaded inside the `InAppBrowser` Webview. | ||
- __download__: _(Android Only)_ event fires when the `InAppBrowser` loads a URL that leads in downloading of a file. | ||
@@ -331,16 +323,39 @@ - __callback__: the function that executes when the event fires. The function is passed an `InAppBrowserEvent` object as a parameter. | ||
``` | ||
#### Download event Example | ||
Whenever the InAppBrowser receives or locates to a url which leads in downloading a file, the callback assigned to the "download" event is called. The parameter passed to this callback is an object with the the following properties | ||
- **type** _it contains the String value "download" always_ | ||
- **url** _The url that leaded to the downloading of file. Basically, the download link of file_ | ||
- **userAgent** _User Agent of the webview_ | ||
- **contentDisposition** _If the url contains "content-disposition" header, then this property holds the value of that field else this field is empty_ | ||
- **contentLength** _If the link of the file allows to obtain file size then this property holds the file size else it contains int value 0_ | ||
- **mimetype** _The MIME type of the file_ | ||
``` | ||
function downloadListener(params){ | ||
var url = params.url; | ||
var mimetype = params.mimetype; | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open("GET", params.url); | ||
xhr.onload = function() { | ||
var content = xhr.responseText; | ||
}; | ||
xhr.send(); | ||
} | ||
``` | ||
### InAppBrowserEvent Properties | ||
- __type__: the eventname, either `loadstart`, `loadstop`, `loaderror`, `message` or `exit`. _(String)_ | ||
- __url__: the URL that was loaded. _(String)_ | ||
- __code__: the error code, only in the case of `loaderror`. _(Number)_ | ||
- __message__: the error message, only in the case of `loaderror`. _(String)_ | ||
- __data__: the message contents , only in the case of `message`. A stringified JSON object. _(String)_ | ||
### Supported Platforms | ||
@@ -351,4 +366,2 @@ | ||
- iOS | ||
- Windows | ||
- OSX | ||
@@ -359,9 +372,5 @@ ### Browser Quirks | ||
### Windows Quirks | ||
`message` event is not fired. | ||
### Quick Example | ||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); | ||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes'); | ||
ref.addEventListener('loadstart', function(event) { alert(event.url); }); | ||
@@ -384,2 +393,3 @@ | ||
- __message__: event fires when the `InAppBrowser` receives a message posted from the page loaded inside the `InAppBrowser` Webview. | ||
- __download__: _(Android only)_ event fires when the `InAppBrowser` loads a URL that leads in downloading of a file. | ||
@@ -394,7 +404,6 @@ - __callback__: the function to execute when the event fires. | ||
- iOS | ||
- Windows | ||
### Quick Example | ||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); | ||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes'); | ||
var myCallback = function(event) { alert(event.url); } | ||
@@ -417,7 +426,6 @@ ref.addEventListener('loadstart', myCallback); | ||
- iOS | ||
- Windows | ||
### Quick Example | ||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); | ||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes'); | ||
ref.close(); | ||
@@ -438,7 +446,6 @@ | ||
- iOS | ||
- Windows | ||
### Quick Example | ||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'hidden=yes'); | ||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'hidden=yes'); | ||
// some time later... | ||
@@ -459,7 +466,6 @@ ref.show(); | ||
- iOS | ||
- Windows | ||
### Quick Example | ||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank'); | ||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank'); | ||
// some time later... | ||
@@ -492,7 +498,6 @@ ref.hide(); | ||
- iOS | ||
- Windows | ||
### Quick Example | ||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); | ||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes'); | ||
ref.addEventListener('loadstop', function() { | ||
@@ -506,6 +511,2 @@ ref.executeScript({file: "myscript.js"}); | ||
### Windows Quirks | ||
Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.controls.webview.invokescriptasync.aspx) the invoked script can return only string values, otherwise the parameter, passed to __callback__ will be `[null]`. | ||
## InAppBrowser.insertCSS | ||
@@ -529,7 +530,6 @@ | ||
- iOS | ||
- Windows | ||
### Quick Example | ||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); | ||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes'); | ||
ref.addEventListener('loadstop', function() { | ||
@@ -716,9 +716,9 @@ ref.insertCSS({file: "mystyles.css"}); | ||
iab.open('http://whitelisted-url.com'); // loads in the Cordova WebView | ||
iab.open('http://whitelisted-url.com', '_self'); // loads in the Cordova WebView | ||
iab.open('http://whitelisted-url.com', '_system'); // loads in the system browser | ||
iab.open('http://whitelisted-url.com', '_blank'); // loads in the InAppBrowser | ||
iab.open('http://whitelisted-url.com', 'random_string'); // loads in the InAppBrowser | ||
iab.open('https://whitelisted-url.com'); // loads in the Cordova WebView | ||
iab.open('https://whitelisted-url.com', '_self'); // loads in the Cordova WebView | ||
iab.open('https://whitelisted-url.com', '_system'); // loads in the system browser | ||
iab.open('https://whitelisted-url.com', '_blank'); // loads in the InAppBrowser | ||
iab.open('https://whitelisted-url.com', 'random_string'); // loads in the InAppBrowser | ||
iab.open('http://whitelisted-url.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar | ||
iab.open('https://whitelisted-url.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar | ||
@@ -732,9 +732,9 @@ ``` | ||
iab.open('http://url-that-fails-whitelist.com'); // loads in the InAppBrowser | ||
iab.open('http://url-that-fails-whitelist.com', '_self'); // loads in the InAppBrowser | ||
iab.open('http://url-that-fails-whitelist.com', '_system'); // loads in the system browser | ||
iab.open('http://url-that-fails-whitelist.com', '_blank'); // loads in the InAppBrowser | ||
iab.open('http://url-that-fails-whitelist.com', 'random_string'); // loads in the InAppBrowser | ||
iab.open('http://url-that-fails-whitelist.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar | ||
iab.open('https://url-that-fails-whitelist.com'); // loads in the InAppBrowser | ||
iab.open('https://url-that-fails-whitelist.com', '_self'); // loads in the InAppBrowser | ||
iab.open('https://url-that-fails-whitelist.com', '_system'); // loads in the system browser | ||
iab.open('https://url-that-fails-whitelist.com', '_blank'); // loads in the InAppBrowser | ||
iab.open('https://url-that-fails-whitelist.com', 'random_string'); // loads in the InAppBrowser | ||
iab.open('https://url-that-fails-whitelist.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar | ||
``` |
@@ -22,13 +22,13 @@ /* | ||
var modulemapper = require('cordova/modulemapper'); | ||
const modulemapper = require('cordova/modulemapper'); | ||
var browserWrap, popup, navigationButtonsDiv, navigationButtonsDivInner, backButton, forwardButton, closeButton; | ||
let browserWrap, popup, navigationButtonsDiv, navigationButtonsDivInner, backButton, forwardButton, closeButton; | ||
function attachNavigationEvents (element, callback) { | ||
var onError = function () { | ||
const onError = function () { | ||
try { | ||
callback({ type: 'loaderror', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal | ||
callback({ type: 'loaderror', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal | ||
} catch (err) { | ||
// blocked by CORS :\ | ||
callback({ type: 'loaderror', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal | ||
callback({ type: 'loaderror', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal | ||
} | ||
@@ -39,6 +39,6 @@ }; | ||
try { | ||
callback({ type: 'loadstart', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal | ||
callback({ type: 'loadstart', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal | ||
} catch (err) { | ||
// blocked by CORS :\ | ||
callback({ type: 'loadstart', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal | ||
callback({ type: 'loadstart', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal | ||
} | ||
@@ -49,6 +49,6 @@ }); | ||
try { | ||
callback({ type: 'loadstop', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal | ||
callback({ type: 'loadstop', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal | ||
} catch (err) { | ||
// blocked by CORS :\ | ||
callback({ type: 'loadstop', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal | ||
callback({ type: 'loadstop', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal | ||
} | ||
@@ -61,3 +61,3 @@ }); | ||
var IAB = { | ||
const IAB = { | ||
close: function (win, lose) { | ||
@@ -81,5 +81,5 @@ if (browserWrap) { | ||
open: function (win, lose, args) { | ||
var strUrl = args[0]; | ||
var target = args[1]; | ||
var features = args[2]; | ||
const strUrl = args[0]; | ||
const target = args[1]; | ||
const features = args[2]; | ||
@@ -208,4 +208,4 @@ IAB._win = win; | ||
injectScriptCode: function (win, fail, args) { | ||
var code = args[0]; | ||
var hasCallback = args[1]; | ||
const code = args[0]; | ||
const hasCallback = args[1]; | ||
@@ -225,3 +225,3 @@ if (browserWrap && popup) { | ||
injectScriptFile: function (win, fail, args) { | ||
var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented'; | ||
const msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented'; | ||
console.warn(msg); | ||
@@ -234,3 +234,3 @@ if (fail) { | ||
injectStyleCode: function (win, fail, args) { | ||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented'; | ||
const msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented'; | ||
console.warn(msg); | ||
@@ -243,3 +243,3 @@ if (fail) { | ||
injectStyleFile: function (win, fail, args) { | ||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented'; | ||
const msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented'; | ||
console.warn(msg); | ||
@@ -246,0 +246,0 @@ if (fail) { |
@@ -23,6 +23,6 @@ /* | ||
(function () { | ||
var exec = require('cordova/exec'); | ||
var channel = require('cordova/channel'); | ||
var modulemapper = require('cordova/modulemapper'); | ||
var urlutil = require('cordova/urlutil'); | ||
const exec = require('cordova/exec'); | ||
const channel = require('cordova/channel'); | ||
const modulemapper = require('cordova/modulemapper'); | ||
const urlutil = require('cordova/urlutil'); | ||
@@ -37,3 +37,4 @@ function InAppBrowser () { | ||
customscheme: channel.create('customscheme'), | ||
message: channel.create('message') | ||
message: channel.create('message'), | ||
download: channel.create('download') | ||
}; | ||
@@ -94,2 +95,6 @@ } | ||
} | ||
}, | ||
addDownloadListener: function (success, error) { | ||
exec(success, error, 'InAppBrowser', 'downloadListener'); | ||
} | ||
@@ -101,3 +106,3 @@ }; | ||
if (window.frames && window.frames[strWindowName]) { | ||
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open'); | ||
const origOpenFunc = modulemapper.getOriginalSymbol(window, 'open'); | ||
return origOpenFunc.apply(window, arguments); | ||
@@ -107,10 +112,10 @@ } | ||
strUrl = urlutil.makeAbsolute(strUrl); | ||
var iab = new InAppBrowser(); | ||
const iab = new InAppBrowser(); | ||
callbacks = callbacks || {}; | ||
for (var callbackName in callbacks) { | ||
for (const callbackName in callbacks) { | ||
iab.addEventListener(callbackName, callbacks[callbackName]); | ||
} | ||
var cb = function (eventname) { | ||
const cb = function (eventname) { | ||
iab._eventHandler(eventname); | ||
@@ -117,0 +122,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
302614
34
520