Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Thursday, December 17, 2009

How to dynamically adjust an iframe’s height?

I was looking to display content of the other aspx page inside iframe but i wasnt able to adjust the height of the iframe. so try out this solution to resolve it.

Insert iframe on page
   <iframe scrolling='no' frameborder='0' id='frmid' src=’getad.aspx'
            onload='javascript:resizeIframe(this);'>
   </iframe>


Use this javascript to resize iframe based on the height & width of child page




<script language="javascript" type="text/javascript">
 function resizeIframe(obj)
 {
   obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
   obj.style.width = obj.contentWindow.document.body.scrollWidth + 'px';
 }
 </script>


What does this code do? When the body of the parent frame loads, it looks up the document element “childframe” which corresponds to the iframe. Then the page calls a function resizeFrame(). The function sets the height of the frame to be the scrollHeight, which effectively removes the scrollbar.

happy programming!

Thursday, November 12, 2009

Statement cannot appear within a method body. End of method assumed

Today when I was developing web pages using asp.net,I encountered a problem as below:
Server Error in '/BC30289' Application.
 
Compilation Error Description:
An error occurred during the compilation of a resource required to service  this request. Please review the following specific error details and modify your  source code appropriately.

Compiler Error Message: 
BC30289:  Statement cannot appear within a method body. End of method assumed.

Error Line: Sub showImage(Byval id as string)
I replaced "<% %>" with
<script language="vbscript" runat="server"></script>

And then everything works fine.

That is because we cannot define asp 'sub' or 'function' between the body tag

--
Happy Programming