使用jQuery关闭iframe时出现的问题
我有下面的场景 在产品显示页面上,当用户单击登录时,登录弹出窗口将在iframe中打开使用jQuery关闭iframe时出现的问题,jquery,iframe,Jquery,Iframe,我有下面的场景 在产品显示页面上,当用户单击登录时,登录弹出窗口将在iframe中打开 jQuery.fancybox({ 'padding' : 0, 'transitionIn' : 'none', 'transitionOut' : 'none', 'scrolling' : 'no', 'autoDimensions' : false, 'autoScale' : false, 'width' : frameWidth, '
jQuery.fancybox({
'padding' : 0,
'transitionIn' : 'none',
'transitionOut' : 'none',
'scrolling' : 'no',
'autoDimensions' : false,
'autoScale' : false,
'width' : frameWidth,
'height' : frameHeight,
'type' : 'iframe',
'href' : _this.attr("href"),
'onComplete' : function() {
$.fancybox.resize();
},
'onClosed' : function() {
if(isReloadOnClose)
closeAndRefresh();
}
});
当用户成功登录时,我将打开另一个弹出窗口,要求用户执行操作
jQuery(document).ready(function() {
window.jQuery('#fancybox-frame').remove();
var productId = document.getElementById("productId").value;
var skuId = document.getElementById("skuId").value;
jQuery.fancybox({
href: "/shop/wishlist-modal-add.jsp?productId="+productId+"&skuId="+skuId,
type: 'ajax',
centerOnScroll: true,
onComplete: function(){
jQuery.fancybox.resize();
},
onClosed: function(){
$('#fancybox-content').css({width:'+=30px;'});
jQuery.fancybox.resize();
}
});
});
我面临的问题是,第二个弹出窗口仅在第一个ifarme中打开,即使我正在移除iframe
请帮助解决此问题。试试这个
parent.jQuery.fn.fancybox.close();
希望这能帮助您尝试调用
parent.$.fancybox.close()
而不是window.jQuery(“#fancybox frame”).remove()代码>嘿,Pete,上面提供的语句确实关闭了iframe,但是它没有加载下一个fancybox。此外,在parent.$.fancybox.close()之后没有任何语句;正在被处决。我还想知道,由于同源策略,这在跨域网络中是否有效?啊,我猜因为您正在实际的iframe中执行脚本,所以无法关闭它。尝试删除前一行,然后像这样调用新的fancybox:parent.jQuery.fancybox({
不确定是否有相同的源代码,尽管我以前使用的是相同的函数parent.jQuery.fancybox({但是由于阶段上的同源策略,它出现了问题,我不得不还原我的更改。我作为父对象出错。jQuery.fn.fancybox.close();不是函数。请原谅,我是ATG开发人员,不是jQuery方面的专家。正如前面所说,这不会在跨域平台上引发问题吗?