Pages

Men

rh

9/30/2014

How to get height of Iframe Control dynamically using Java Script in asp.net with C#

<table>
 <tr >
       <td >
                  
                    <iframe id="ifrm1" runat="server" scrolling="auto" width="100%"></iframe>
          </td>
  </tr>

</table>

Script :-
 <script type="text/javascript" language="javascript">

         function ResizeReport() {

             var rep = document.getElementById("<%= ifrm1.ClientID %>");

             var htmlheight = document.documentElement.clientHeight;
             var htmlwidth = document.documentElement.clientWidth;
             rep.style.height = (htmlheight - 140) + "px";
             rep.style.width = (htmlwidth - 100) + "px";
             window.alert(rep.style.height);
             window.alert(htmlheight);
         }
         ResizeReport();
         window.onresize = function Resize() { ResizeReport() };

</script>


in asp.net page in Page_load event, we have to write in below way.

  ifrm1.Attributes.Add("onload", "ResizeReport();");

No comments :

Post a Comment