Use onload property for server side controls- iFrame

Posted by Sharpcnet under JavaScript on 2/23/2014 | Points: 10 | Views : 1962 | Status : [Member] | Replies : 0
I'm trying to use the onload property for an iFrame.

<script type="text/javascript">
function iframeLoaded() {
var iFrameID = document.getElementById('iframe1');
if(iFrameID) {
// here you can make the height, I delete it first, then I make it again
iFrameID.height = "";
iFrameID.height = iFrameID.contentWindow.document.body.scrollHeight + "px";

<iFrame id="iframe1" runat="server" onload="iframeLoaded()"></iFrame> 

This code works only when the runat="server" is removed. Or else it is not recognizing the iframe id.
I tried also with document.getElementById('<%iframe1.ClientID%>');

I also tried the solution at
It now gives an error - No overload for method takes 0 arguments. What should be passed?


(No response found.)

Login to post response