I would like to reuse the same selector class for multiple fancybox iframes. I have looked at different posts here on SO regarding sizing iframe content into fancybox. While all the ones I looked at seemed that they would work (I am currenty using JFK's solution here), I an unable to get it, or some of the others to work on my pages. I looked up "fancybox-iframe" class in firebug, it reads as "fancybox-type-iframe" class. Could someone let me know what is wrong with the code I'm using below, why it is wrong and how to fix it. Linked answers, jsfiddles, etc. are fine too. Used inline for fancyboxes containing a small amount of content, but I'd like to use the iframe for pages. Thanks!
Here is the complete code.
This link to open fancybox is on a different page within domain
<a href="thm12.html" class="openfb"></a>
HTML page to show in fancybox
<!DOCTYPE html >
<html style="width:550px;height:350px;" >
<head>
<title>THM - Twelve</title>
<script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
<script src="../js/ui/jquery.ui.core.js"></script>
<script src="../js/ui/jquery.ui.widget.js"></script>
<script src="../js/ui/jquery.ui.mouse.js"></script>
</script>
</head>
<body>
<div class="thm-set">
<p class="thm-set-title" >Start Settings</p>
<form id="" class="default-set-thm" >
<div class="thm-content" ><p>Lorem ipsum aenean tempus lacus vitae orci
posuere porttitor eget non felis. Donec lectus elit, aliquam nec eleifend sit amet.</p><input type="text" value="" placeholder="" /></div>
<span class="buttons">
<input type="submit" class="close-fancybox" value=""/>
<input type="submit" class="save-fancybox" value="" />
</span>
</form>
</div>
</body>
</html>
fancybox js script
$(".openfb").fancybox({
hideOnContentClick: false,
type:'iframe',
scrolling: 'no',
beforeShow: function(){
this.width = ($('.fancybox-iframe').contents().find('html').width());
alert("the width of this div is " + this.width);
this.height = ($('.fancybox-iframe').contents().find('html').height());
}
});
Chrome alert results
Firefox alert results
IE 9 alert result: