This plugin provide capability of open multiple webview, and you can open a new webview in sub webview page.
English | 中文介绍
- Android
- iOS
cordova plugin add cordova-plugin-openwebview
- cordova.plugins.openWebview.open
cordova.plugins.openWebview.open(openOptions, openSuccess, openError);
- openOptions
- openSuccess
- openError
Options | Required | Data Type | Default Value | Description |
---|---|---|---|---|
url | true | String | null | Target url open in webview, not null. |
inSubView | false | Boolean | false | Default open webview with full screen, if value is true, the effect will like demo. |
showBackBtn | false | Boolean | false | Default hide back button, if value is true, will show it. |
var openOptions = {
url: "https://www.google.com",
inSubView: false,
showBackBtn: false
};
function openSuccess(data) {
console.log(data);
}
function openError(error) {
console.log(error);
}
cordova.plugins.openWebview.open(openOptions, openSuccess, openError);
You can use below methods open a new webview in a sub webview page which has been opened with cordova.plugins.openWebview.open
, the method only have one option and same as openOptions.
- window.webkit.messageHandlers.openNew.postMessage (iOS)
- openWebview.openNew (Android)
var openOptions = {
url: "https://www.google.com",
inSubView: false,
showBackBtn: false
};
window.webkit.messageHandlers.openNew.postMessage(openOptions);
var openOptions = {
url: "https://www.google.com",
inSubView: false,
showBackBtn: false
};
openWebview.openNew(JSON.stringify(openOptions));
If you want to open url with system browser, only need add #webview-external
to the end of url.
var openOptions = {
url: "https://www.google.com#webview-external"
};
cordova.plugins.openWebview.open(openOptions);
// or
window.webkit.messageHandlers.openNew.postMessage(openOptions);
// or
openWebview.openNew(JSON.stringify(openOptions));
- Custom action bar background color
- Custom open webview sum(currently only two webviews can be opened)
- Post custom message form sub webview
Copyright (c) 2020, Vason