Iframe auto resize increase and decrease

I found the solution here How to auto shrink iframe height dynamically?

I'm trying to Iframe a forum and i need to autosize increasing and decreasing the size of Iframe.

Now i have this:

   <script language="JavaScript" type="text/javascript">
    function autoResize(id){
        var newheight;
        var newwidth;

            newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
            newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;

        document.getElementById(id).height= (newheight) + "px";
        document.getElementById(id).width= (newwidth) + "px";
    <iframe frameborder="0" height="200px" id="iframe1" marginheight="0" onload="autoResize('iframe1');" src="/forum" width="100%"></iframe>

But this code only increase the size and i need also decrease the size.



Try using offsetHeight, rather than scrollHeight.

You might find this library useful, as it also detects a few different events that can cause you to need to resize your iFrame.


Need Your Help

Mysql query for finding word stored in another table

mysql sql mysqli

I have two mysql tables search_words(id,word) and search_text_data(id,text)

Unable to resolve hostname over vpn

c# wcf xamarin xamarin.ios xamarin.forms

I've been trying get my app to connect to a WCF service within the corporate network.