Set height for iFrame using jquery

15 comments
$(document).ready(function () {
var height = $(window.frameElement).height(); // Calculate the window height
var minheight = $(window.frameElement).height(); // Calculate the window min-height
$(window.top.document).find('iframe').css("height", (height - 20) + "px"); // Calculated window height - header height + footer height + padding + margin , then you will get the remaining height for the main container
$(window.top.document).find('iframe').css("min-height", (minheight - 20) + "px"); // Calculated window minheight - header height + footer height + padding + margin , then you will get the remaining min-height for the main container
$(window.top.document).find('iframe').css("width", "100%");
});

// Resize Function
$(window).resize(function () {
var height = $(window.frameElement).height(); // Calculate the window height
var minheight = $(window.frameElement).height(); // Calculate the window min-height
$(window.top.document).find('iframe').css("height", (height - 20) + "px"); // Calculated window height - header height + footer height + padding + margin , then you will get the remaining height for the main container
$(window.top.document).find('iframe').css("min-height", (minheight - 20) + "px"); // Calculated window minheight - header height + footer height + padding + margin , then you will get the remaining min-height for the main container
});

15 comments :

Post a Comment