1

In an .aspx page with a VB.NET codebehind I am using an IFRAME which would be created inside the repeater control.

Since I want to resize the IFRAME based on the content within the page I have been using the resize function obtained from here on the IFRAME onload as shown below.

<iframe id="IframeSubsectionArea" scrolling="auto" width="100%" onload="resizeIframeToFitContent(this)" runat="server">

However it is throwing an error as the method could not be found in the form.

  1. Is there any client side script variant for the onload event?
  2. What might be the reason for the error and its solution?
moberley
  • 365
  • 4
  • 12
balu
  • 322
  • 4
  • 13

1 Answers1

3

If you don't mind using jQuery the first answer on here should do the trick jQuery .ready in a dynamically inserted iframe

$(document).ready(function() {
   $("iframe").load(function() {
        var iframe = $(this);

        //Do your resize here via the iframe var
   });
 });

Failing that, you may be getting the error due to this block of code being missing from your document however as you have not posted the actual error i cannot be sure.

<SCRIPT LANGUAGE="JavaScript">
function resizeIframeToFitContent(iframe) {
    // This function resizes an IFrame object
    // to fit its content.
    // The IFrame tag must have a unique ID attribute.
    iframe.height = document.frames[iframe.id]
                    .document.body.scrollHeight;
}
</SCRIPT>

Edit: If that doesn't work post some example code, and the actual error you are getting

Community
  • 1
  • 1
Hawxby
  • 2,746
  • 21
  • 29
  • As i couldn't implement the suggestion in the application as the whole idea was dropped.However the suggestion worked.Thank you Hawxby. +1 for that. – balu Feb 21 '11 at 12:57