Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to know iframe is completeley loaded or not programtically?
There is one iframe in mypage...,at runtime i will set src attribute of this iframe , after iframe loaded i want to set height and width of this iframe and then open that iframe in to jdialog using jquery...

code look like this...
<script type="javascript">
           function ShowDialog() {
           $("#ifrmmodify").attr("src","Default2.aspx");
            //here after this page load completely in iframe i want to set height and width of this iframe.then
          $("#dvmodify").dialog();
       }
</script>
<form>
<div id="dvmodify">
            
           <iframe id="ifrmmodify"/>

</div>
</form>
Posted
Updated 19-Jan-11 7:46am
v3
Comments
TweakBird 19-Jan-11 13:26pm    
Edited for code blocks.

Use event onload of your iframe.
Just one example: http://www.w3schools.com/jsref/event_frame_onload.asp[^].
 
Share this answer
 
Comments
jatinchandarana 19-Jan-11 13:45pm    
this i frame is inside div and after iframe completely loaded i want to open dialog , i i write onload event then when page first time load a dialog will open pls see the code i write...
Sergey Alexandrovich Kryukov 19-Jan-11 15:43pm    
In your unload handler, open the dialog or whatever, why it's a problem?
Manfred Rudolf Bihy 19-Jan-11 15:42pm    
Looks like another unavailing effort on my side, but I tried what you proposed as an experiment and lo and behold it works. I just can't tell why they don't put the advice to use that we pour on them daily.
Sergey Alexandrovich Kryukov 19-Jan-11 15:44pm    
So it works? Great. I did not expect someone would bother to code and test it. I already voted 5" for you.
Espen Harlinn 19-Jan-11 15:50pm    
5+ Good link and verified by Manfred, that's a good community effort :)
Hi I put together an example look here:

XML
<html>
<head>
    <link rel="stylesheet" href="./scripts/css/ui-lightness/jquery-ui-1.8.8.custom.css"/>
    <script type="text/javascript" src="./scripts/jquery-1.4.4.js"></script>
    <script type="text/javascript" src="./scripts/js/jquery-ui-1.8.8.custom.min.js"></script>
</head>
<body>
    <div id="dvmodify">
        <iframe id="ifrmmodify"></iframe>
    </div>
    <script type="text/javascript">
        function ShowDialog() {
            // setting the width and height of the iframe I leave to you
            $("#dvmodify").dialog();
        }

        function SetIFrameSource() {
            $("#ifrmmodify").attr("src", "./Test.html");
            $("#ifrmmodify").load(ShowDialog);
        }

        $(function() { SetIFrameSource(); });
    </script>
</body>
</html>


I hope this gives you an idea how to accomplish your task!

Best Regards,
Manfred
 
Share this answer
 
v2
Comments
Espen Harlinn 19-Jan-11 15:51pm    
Good work Manfred :)
Manfred Rudolf Bihy 19-Jan-11 16:34pm    
Thanks Espen!
jatinchandarana 20-Jan-11 12:21pm    
thank you it help me...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900