admin管理员组

文章数量:1327709

I'm trying to load an iFrame in to colorbox using an onload event - seems like it should be simple but I'm getting the error "the content failed to load"

Here's my code:

<script type="text/javascript"> 
    $(document).ready(function(){ 
    $.colorbox({href:"", open: true});
    }); 
</script> 

Any ideas as to why this may not be working?

I'm trying to load an iFrame in to colorbox using an onload event - seems like it should be simple but I'm getting the error "the content failed to load"

Here's my code:

<script type="text/javascript"> 
    $(document).ready(function(){ 
    $.colorbox({href:"http://www.google.", open: true});
    }); 
</script> 

Any ideas as to why this may not be working?

Share Improve this question asked May 11, 2012 at 9:56 user319940user319940 3,3178 gold badges40 silver badges54 bronze badges 4
  • 1 you try adding iframe: true to the call – gunnx Commented May 11, 2012 at 10:00
  • *facepalm" thanks! worked perfectly. Please put it as an answer so I can accept :P. – user319940 Commented May 11, 2012 at 10:03
  • colorbox is one of my favourite lightboxes, use it regularly. – gunnx Commented May 11, 2012 at 10:04
  • Seems good so far, I'm sure I'll have a few more mishaps but seems like a lot of people use it. – user319940 Commented May 11, 2012 at 10:07
Add a ment  | 

2 Answers 2

Reset to default 4

You need to add iframe: true to the function call

I made this Fiddle to test that issue, and concluded that it has a weird behavior when the width and the height are not set, so this way I did solved the issue:

JQUERY

$(document).ready(function(){
  $.colorbox({
    iframe      : true,
    innerWidth  : 425,
    innerHeight : 344,
    href        : "http://www.youtube./embed/617ANIA5Rqs?rel=0&wmode=transparent"
  });
});

本文标签: javascriptonLoad iFrame with ColorboxStack Overflow