【发布时间】:2015-02-26 08:36:39
【问题描述】:
我在引导模式中使用 iFrame 时遇到问题。它是一个新闻系统,我从另一个子域的 iFrame 加载新闻内容。一切正常,如果用户单击任何新闻项目中的图像,我想在父窗口中打开一个灯箱(Fancybox)。这通常不是问题,我正在使用这样的东西:
// so i know its an Popup / has an iFrame (class Popup is when it is opened in an BS Modal) - otherwise ill go to my news size and show the article there.
$('a[rel="lightbox"]').click(function(e) {
e.preventDefault();
var link = $(this).attr('href');
if ($(this).closest('body').hasClass('popup')) {
parent.$.fancybox({
// this is without any popup
$.fancybox({
href: link,
...
我的图片位于另一个域 - 例如 static.site.com。当生病去 news.site.com - 并打开一个弹出窗口(现在它来自同一个域) - 并单击图像 - 一切都很好,
parent.$
工作正常。
但是,当我从主站点(www.site.com)打开模态(来自 news.site.com 的内容)然后单击图像(static.site.com)时出现以下错误:
Error: Permission denied to access property '$'
我已经允许 PHP 标头从另一个子域加载内容 - 但仍然会出现此错误。
我是否需要使用 JSONP(将页面内容加载为 HTML?) - 还是有其他更简单的解决方案?
【问题讨论】:
标签: html iframe modal-dialog lightbox