From 95edf619f048b08c980acbcdf0cc5012e47a5122 Mon Sep 17 00:00:00 2001 From: dpalou Date: Tue, 13 Nov 2018 13:54:36 +0100 Subject: [PATCH] MOBILE-2728 iframe: Allow navigating in online frames --- src/providers/utils/iframe.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/providers/utils/iframe.ts b/src/providers/utils/iframe.ts index 44031c49c..23c83ff70 100644 --- a/src/providers/utils/iframe.ts +++ b/src/providers/utils/iframe.ts @@ -317,8 +317,26 @@ export class CoreIframeUtilsProvider { } if (scheme && scheme != 'file' && scheme != 'filesystem') { - // Scheme suggests it's an external resource, open it in browser. + // Scheme suggests it's an external resource. event.preventDefault(); + + const frameSrc = element.src || element.data, + frameScheme = this.urlUtils.getUrlScheme(frameSrc); + + // If the frame is not local, check the target to identify how to treat the link. + if (frameScheme && frameScheme != 'file' && frameScheme != 'filesystem' && + (!link.target || link.target == '_self')) { + // Load the link inside the frame itself. + if (element.tagName.toLowerCase() == 'object') { + element.setAttribute('data', link.href); + } else { + element.setAttribute('src', link.href); + } + + return; + } + + // The frame is local or the link needs to be opened in a new window. Open in browser. if (!this.sitesProvider.isLoggedIn()) { this.utils.openInBrowser(link.href); } else {