diff options
author | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-07-15 08:35:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-15 08:35:43 +0300 |
commit | feee14bfaf2bd53d92048c77d36bfce42291ddd5 (patch) | |
tree | 6985cf6fe2b064cd72a9a45b368c1b20c242b985 /js | |
parent | fc50d2b80810f2c34e2b58ef41ad970e3c5b261d (diff) |
Fixes #10105 - copied from #10271 by @Kijewski (#10306)
Diffstat (limited to 'js')
-rw-r--r-- | js/piwik.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/js/piwik.js b/js/piwik.js index 07c921b1bb..db331f7150 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -2731,13 +2731,24 @@ if (typeof window.Piwik !== 'object') { } function isInsideAnIframe () { - if (isDefined(windowAlias.frameElement)) { - return (windowAlias.frameElement && String(windowAlias.frameElement.nodeName).toLowerCase() === 'iframe') ? true : false; + var frameElement; + + try { + // If the parent window has another origin, then accessing frameElement + // throws an Error in IE. see issue #10105. + frameElement = windowAlias.frameElement; + } catch(e) { + // When there was an Error, then we know we are inside an iframe. + return true; + } + + if (isDefined(frameElement)) { + return (frameElement && String(frameElement.nodeName).toLowerCase() === 'iframe') ? true : false; } try { return windowAlias.self !== windowAlias.top; - } catch (e) { + } catch (e2) { return true; } } |