From 99a17c4ad454ec4eac3394bb224bb3ad738fdf8f Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 27 Aug 2015 22:23:23 +0000 Subject: [PATCH] webstaff: add routine for Dojo JS to detect if running in iframe Sometimes legacy Dojo interfaces may need to adjust their behavior if they're embedded in the web staff client. This patch adds a new utility function, openils.Util.inIFrame(), to detect if such code is running in an iframe. If so, the presumption is that iframe belongs to the web staff client. Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- Open-ILS/web/js/dojo/openils/Util.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Open-ILS/web/js/dojo/openils/Util.js b/Open-ILS/web/js/dojo/openils/Util.js index 804d13c3c4..e3588ae61f 100644 --- a/Open-ILS/web/js/dojo/openils/Util.js +++ b/Open-ILS/web/js/dojo/openils/Util.js @@ -494,5 +494,19 @@ if(!dojo._hasResource["openils.Util"]) { ); }; + /** + * Check to see if we're running in an iframe; if we + * are, we assume that the iframe is specifically one + * used by the web staff client to embed legacy interfaces. + */ + openils.Util.inIframe = function() { + /* http://stackoverflow.com/a/326076 */ + try { + return window.self !== window.top; + } catch (e) { + return true; + } + }; + } -- 2.43.2