iFrame height adjust with jQuery

I would like to auto-adjust the height of my iframe to the content that's in it. I've done this with a jQuery plugin, jquery-iframe-auto-height by house9, which works really well.

Now I want for my homepage (in the iframe) to have the full height of the parent page. I figured I should use an if else statement, but since I'm not that experienced with javascript (yet), I hope one of you could help me.

$(document).ready(function () {
    if ((#ifrm).($this).attr('src') == 'home.html'){
        $('#ifrm').iframeAutoHeight({minHeight: 100%});
    else $('#ifrm').iframeAutoHeight({minHeight: 300});

Also I found this one code for getting the full height of the page, maybe it helps

if ($('#ifrm').($this).attr('src') == 'home.html'){
    (function(){var height = $(window).height();
         $('#ifrm').css('height', height)
    else $('#ifrm').iframeAutoHeight({minHeight: 300, debug: true});

Thank you so much in advance

Edit: you can find the website this was for here


This code should work for you:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

    $(document).ready(function() {
        if ($('#ifrm').attr('src') == 'home.html') {
            var window_height = $(window).height();
            $('#ifrm').css("height", window_height);
            $('#ifrm').load(function() {
                this.style.height =
                this.contentWindow.document.body.offsetHeight + 'px';

<iframe src="home.html" id="ifrm">

It not only auto adjusts the height of the iframe to the content without using a plugin (always preferable), it also sets the full height of the "home.html" page

Bear in mind that this will only work if the iframe contents are on the same domain, the contents of iframes from other domains are locked out for security.

Need Your Help

Globalization in jquery and asp.net. How?

javascript jquery asp.net localization globalization

Is there a jquery plugin for the globalization of asp.net web application?

PHP Regex Parse query string containing un-encoded ampersands

php regex parsing query-string ampersand

I'm receiving a query string (from a terrible payment system whose name I do not wish to sully publicly) that contains un-encoded ampersands

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.