views:

89

answers:

1

Hi,

I am using the following javascript to resize an iframe. The top level page is written is classic asp and contains and iframe into which I am loading a control which is written in .net and ajax. The issue is, that the page size is dynamic depending on content, and also takes a while to load. What happens at the moment is that the page loads, the ajax control loads and scroll bars appear till the contents is fully loads, and then it is resized to fit correctly. Obviously it would be nice if the page was the correct size in the first place whilst the ajax finishes loading the content. Is there a precursor to the onload event in classic asp that I can use?

I want to stay away from one of those 'loading page' images.

function autoIframe() {
    try {
        frame = document.getElementById("browse_frame");
        innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
        objToResize = (frame.style) ? frame.style : frame;
        objToResize.height = innerDoc.body.scrollHeight + 10 + "px";

    }
    catch (err) {
        window.status = err.message;
    }
}
window.onload = autoIframe;

Thanks, R.

A: 

If you just put the script inline (not within a function) within your ASP page, it will be run directly (without waiting for the onload function).

E.g.

<html><head>
<script language=javascript>

// run straight away without waiting for an event
alert ("running inline");

// function which will run when onload event fires
function onloaded() {
   alert("onload event");
}
</script>
</head>

<body onload='onloaded();'>Hello World</body>
</html>

That way you can just put your resize code into inline script directly AFTER the IFRAME tags on your HTML page. Hope that helps...

Thanks, I'd totally forgotten about doing that.
flavour404