nit*_*suj 0 javascript jquery colorbox
我需要通过onclick事件关闭覆盖网站的colorbox iframe.我已经看过代码了parent.$.colorbox.close(); return false;,但是当我像这样使用它时它对我不起作用:<a onclick="parent.$.colorbox.close(); return false;">close</a>.我认为这是因为我没有使用标准的颜色框脚本来调用iframe.我修改它,以便我可以从html锚标记获取高度和宽度:
我的COLORBOX SCRIPT:
$.noConflict();
jQuery(document).ready(function($){
$("a[rel='colorbox']").each(function(){
var getWidth = parseInt($(this).attr('width'))
var getHeight = parseInt($(this).attr('height'))
var getScroll = parseInt($(this).attr('scrolling'))
if(getScroll == 'yes') { var frameScroll = 'true'; }
if(!getWidth) { var getWidth = '720'; }
if(!getHeight) { var getHeight = '480'; }
$(this).colorbox({innerWidth:getWidth, innerHeight:getHeight, scrolling:frameScroll, iframe:true, rel:"nofollow", transition:"elastic"});
});
});
Run Code Online (Sandbox Code Playgroud)
我需要用什么来关闭这个iframe onclick?
而不是这个:
parent.$.colorbox.close(); return false;
Run Code Online (Sandbox Code Playgroud)
用这个:
parent.jQuery.colorbox.close(); return false;
Run Code Online (Sandbox Code Playgroud)
你正在调用noConflict,它将jQuery与$别名分开.因此,你的iframe无法通过$别名访问jQuery.