简体   繁体   中英

colorbox close button with iframe

I am using colorbox for modal popup and the content of the popup is coming from a URL since this is displayed inside an iFrame how can I add a close button to the modal popup?

Thanks

This is the code for color box

<a class="Modal" href="http://google.com" onclick="openModal();">Click here</a>

And the js:

var openModal = function (){        
     $(".Modal").colorbox({
         iframe:true, 
         opacity:0.5, 
         scrolling:true, 
         width:832, 
         height:456, 
         top:60
     });
}

尝试将此添加到colorbox-iframe.html

<input type="button" name="btnClose" value="Close" onclick="parent.$.colorbox.close()" />

I've never used colorbox before, but maybe you want to add the close button via jQuery in your function:

var openModal = function (){        
     $(".Modal").colorbox({
         iframe:true, 
         opacity:0.5, 
         scrolling:true, 
         width:832, 
         height:456, 
         top:60
     });

     $("<div class='thisClosesTheModal'>Close Modal</div>").appendTo(".Modal");
     // style .thisClosesTheModal to look like a close box
}

// and then the function that closes the modal

$(".thisClosesTheModal").live('click', function(){

   $('Modal').hide();

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM