Use onload property for server side controls- iFrame

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

JS:
<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";
}
}
</script>

ASPX:
<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 http://stackoverflow.com/questions/13854573/iframe-error-when-runat-server.
It now gives an error - No overload for method takes 0 arguments. What should be passed?




Responses

(No response found.)

Login to post response