Reputation: 25058
I have:
$("#fancybox-manual-b").click(function() {
$.fancybox.open({
href : 'iframe.html',
type : 'iframe',
padding : 5
});
});
<li><a class="fancybox fancybox.iframe" href="iframe.html">Iframe</a></li>
however I would like to Adjust size of iframe depending on user screen's size.
I was trying something like:
width = $(window).width() -80;
heigth= $(window).height() -80;
Is this correct?, how to use it in code?
Upvotes: 0
Views: 4393
Reputation: 48
Alternatively, you can also try this..
<script type="text/javascript">
$(document).ready(function () {
$("a.iframe").fancybox({
'width': 800,
'height': 500,
'transitionIn': 'elastic',
'transitionOut': 'elastic',
'type': 'iframe'
});
});
</script>
ND
Upvotes: 2
Reputation: 48
Try this,
function ResizeIframe(iframe) {
var iframeBody = (iframe.contentDocument) ? iframe.contentDocument.body : iframe.contentWindow.document.body;
var height = (iframeBody.scrollHeight < iframeBody.offsetHeight) ? iframeBody.scrollHeight : iframeBody.offsetHeight;
height = height + 10;
$(iframe).height(height);
}
<iframe id="idFrm" src="URL" frameborder="0" clientidmode="Static" scrolling="no" height="35px" width="98%" onload="javascript:ResizeIframe(this);"></iframe>
I have used it and works like charm in all browsers. Call it onload of your
ND
Upvotes: 0