From 7cc03d63a2ce870ab17d7488881b3e3ebb446abf Mon Sep 17 00:00:00 2001 From: Marcello Barnaba Date: Thu, 15 Nov 2012 16:22:02 +0100 Subject: [PATCH 1/3] Add IFRAME support for URLs outside the Same-Origin --- src/facebox.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/facebox.js b/src/facebox.js index 392adf8..b925c42 100644 --- a/src/facebox.js +++ b/src/facebox.js @@ -245,9 +245,17 @@ // image } else if (href.match($.facebox.settings.imageTypesRegexp)) { fillFaceboxFromImage(href, klass) - // ajax + // iframe / ajax } else { - fillFaceboxFromAjax(href, klass) + var host = href.match(/^(?:ht|f)tps?:\/\/([^\/]+)/); + + if (host) + host = host[1]; + + if (!host || host == document.location.host) + fillFaceboxFromAjax(href, klass); + else + fillFaceboxFromIframe(href, klass); } } @@ -263,6 +271,19 @@ $.facebox.jqxhr = $.get(href, function(data) { $.facebox.reveal(data, klass) }) } + function fillFaceboxFromIframe(href, klass) { + var doc = $(document), iframe = $('