(all platforms): remove "window.open" overwrite (#600)

Closes #599
This commit is contained in:
Niklas Merz 2020-04-14 15:25:54 +02:00 committed by GitHub
parent 548f19ca90
commit 074d4d03ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 21 deletions

View File

@ -43,6 +43,10 @@ InAppBrowser window, by replacing window.open:
window.open = cordova.InAppBrowser.open;
If you change the browsers `window.open` function this way, it can have unintended side
effects (especially if this plugin is included only as a dependency of another
plugin).
The InAppBrowser window behaves like a standard web browser,
and can't access Cordova APIs. For this reason, the InAppBrowser is recommended
if you need to load third-party (untrusted) content, instead of loading that
@ -52,22 +56,6 @@ whitelist, nor is opening links in the system browser.
The InAppBrowser provides by default its own GUI controls for the user (back,
forward, done).
For backwards compatibility, this plugin also hooks `window.open`.
However, the plugin-installed hook of `window.open` can have unintended side
effects (especially if this plugin is included only as a dependency of another
plugin). The hook of `window.open` will be removed in a future major release.
Until the hook is removed from the plugin, apps can manually restore the default
behaviour:
delete window.open // Reverts the call back to its prototype's default
Although `window.open` is in the global scope, InAppBrowser is not available until after the `deviceready` event.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log("window.open works well");
}
## Installation
cordova plugin add cordova-plugin-inappbrowser

View File

@ -37,7 +37,6 @@
<platform name="android">
<js-module src="www/inappbrowser.js" name="inappbrowser">
<clobbers target="cordova.InAppBrowser.open" />
<clobbers target="window.open" />
</js-module>
<config-file target="res/xml/config.xml" parent="/*">
<feature name="InAppBrowser">
@ -71,7 +70,6 @@
<platform name="ios">
<js-module src="www/inappbrowser.js" name="inappbrowser">
<clobbers target="cordova.InAppBrowser.open" />
<clobbers target="window.open" />
</js-module>
<config-file target="config.xml" parent="/*">
<feature name="InAppBrowser">
@ -95,7 +93,6 @@
<platform name="osx">
<js-module src="www/inappbrowser.js" name="inappbrowser">
<clobbers target="cordova.InAppBrowser.open" />
<clobbers target="window.open" />
</js-module>
<config-file target="config.xml" parent="/*">
<feature name="InAppBrowser">
@ -111,7 +108,6 @@
<platform name="windows">
<js-module src="www/inappbrowser.js" name="inappbrowser">
<clobbers target="cordova.InAppBrowser.open" />
<clobbers target="window.open" />
</js-module>
<js-module src="src/windows/InAppBrowserProxy.js" name="InAppBrowserProxy">
<runs />
@ -123,7 +119,6 @@
<platform name="browser">
<js-module src="www/inappbrowser.js" name="inappbrowser">
<clobbers target="cordova.InAppBrowser.open" />
<clobbers target="window.open" />
</js-module>
<js-module src="src/browser/InAppBrowserProxy.js" name="InAppBrowserProxy">
<runs />