Jay
Jay

Reputation: 2527

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
     });
}

Upvotes: 2

Views: 5214

Answers (2)

Sammy
Sammy

Reputation: 3099

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();

}

Upvotes: 0

coder
coder

Reputation: 13250

Try adding this to colorbox-iframe.html

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

Upvotes: 8

Related Questions