colorbox弹窗,需求:onclick时候,如果DOM已经ready了,执行ModalPopup,否则点击后不要有反应,请问要怎么写?
如果只按照下面写法,ie7以上,ff,是没问题的,但是IE6容易出问题,页面刚显示就立即点击的话,ie6会没反应,而且此时即使等页面全面ready,还是没反应,永远点不了。
<a href="#" onClick="javascript:ModalPopup('xxx.asp')">function ModalPopup(url,width,height,title)
{
$.fn.colorbox({ iframe: true , innerWidth: 500, innerHeight: 400, title: "标题", opacity: 0.7, href: url });
}官方提供的方法:
$(document).ready(function() {
$(".modalChangeBoard").colorbox({ innerWidth: 520, innerHeight: 235, title: "标题", opacity: 0.65, iframe: true });
这个是代码和html分离的jquery写法,问题是,当没有ready时候,点击链接,会直接打开页面,而没有了弹窗效果。