iframe height auto-resize in asp.net c#

iframe in asp.net c#

Automatically resize the height of an iframe based on its content.
Default.aspx
iframe Ex : <a href="http://www.blogger.com/About.aspx?ref=temp.htm" title="iframe in asp.net c#,iframe height dynamically">Click Here</a>.
About.aspx
        $.urlParam = function (name) {
            var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
            if (!results) {
                return 0;
            }
            return results[1] || 0;
        }

        var langval = $.urlParam('ref');

        $(function () {
            if ($.browser.msie) {
                frames['i1'].window.location = langval;
            } else {
                $("#i1").attr("src", langval);
            }
        });

        function getDocHeight(doc) {
            doc = doc || document;
            var body = doc.body, html = doc.documentElement;
            var height = Math.max(body.scrollHeight, body.offsetHeight,
        html.clientHeight, html.scrollHeight, html.offsetHeight);
            return height;
        }

        function setIframeHeight(id) {
            var ifrm = document.getElementById(id);
            var doc = ifrm.contentDocument ? ifrm.contentDocument :
        ifrm.contentWindow.document;
            ifrm.style.visibility = 'hidden';
            ifrm.style.height = "10px"; // reset to minimal height ...
            ifrm.style.height = getDocHeight(doc) + "px";
            ifrm.style.visibility = 'visible';
        }
        
        }
<iframe src="about:blank" frameborder="0" id="i1" onload="setIframeHeight(this.id)" scrolling="no" style="border: 0px;"></iframe>
iframe height auto-resize in asp.net c# iframe height auto-resize in asp.net c# Reviewed by Bhaumik Patel on 2:22 AM Rating: 5