Improve browser/Cordova compatibility
This commit is contained in:
parent
c68fc954a3
commit
fe5a15d566
@ -176,37 +176,48 @@ function initCordova() {
|
||||
}, function (err) {});
|
||||
|
||||
window.htmlopen = window.open;
|
||||
window.open = cordova.InAppBrowser.open;
|
||||
if (typeof device != "undefined" && device.platform != "browser") {
|
||||
window.open = cordova.InAppBrowser.open;
|
||||
|
||||
openBrowser = function (url, options, onclose, onmessage) {
|
||||
if (typeof options == "undefined") {
|
||||
options = "location=yes,fullscreen=no,zoom=no";
|
||||
}
|
||||
cordovaInAppBrowserRef = cordova.InAppBrowser.open(url, "_blank", options);
|
||||
if (typeof onclose == "function") {
|
||||
try {
|
||||
cordovaInAppBrowserRef.removeEventListener("exit");
|
||||
} catch (ex) {
|
||||
openBrowser = function (url, options, onclose, onmessage) {
|
||||
if (typeof options == "undefined") {
|
||||
options = "location=yes,fullscreen=no,zoom=no";
|
||||
}
|
||||
cordovaInAppBrowserRef.addEventListener("exit", onclose);
|
||||
}
|
||||
if (typeof onmessage == "function") {
|
||||
try {
|
||||
cordovaInAppBrowserRef.removeEventListener("message");
|
||||
} catch (ex) {
|
||||
cordovaInAppBrowserRef = cordova.InAppBrowser.open(url, "_blank", options);
|
||||
if (typeof onclose == "function") {
|
||||
try {
|
||||
cordovaInAppBrowserRef.removeEventListener("exit");
|
||||
} catch (ex) {
|
||||
}
|
||||
cordovaInAppBrowserRef.addEventListener("exit", onclose);
|
||||
}
|
||||
if (typeof onmessage == "function") {
|
||||
try {
|
||||
cordovaInAppBrowserRef.removeEventListener("message");
|
||||
} catch (ex) {
|
||||
}
|
||||
cordovaInAppBrowserRef.addEventListener("message", onmessage);
|
||||
}
|
||||
cordovaInAppBrowserRef.addEventListener("message", onmessage);
|
||||
}
|
||||
}
|
||||
|
||||
closeBrowser = function () {
|
||||
if (typeof cordovaInAppBrowserRef != null) {
|
||||
cordovaInAppBrowserRef.close();
|
||||
closeBrowser = function () {
|
||||
if (typeof cordovaInAppBrowserRef != null) {
|
||||
cordovaInAppBrowserRef.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
openExternalBrowser = function (url) {
|
||||
window.open(url, '_system', '');
|
||||
openExternalBrowser = function (url) {
|
||||
window.open(url, '_system', '');
|
||||
}
|
||||
} else {
|
||||
// Running in browser, use a "real" window instead of an IAB one
|
||||
openBrowser = function (url) {
|
||||
window.open(url);
|
||||
}
|
||||
|
||||
openExternalBrowser = function (url) {
|
||||
window.open(url);
|
||||
}
|
||||
}
|
||||
|
||||
IonicDeeplink.onDeepLink(function (link) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user