Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET jQuery IFrame
Hi,
i have a asp page that contains linkButtons and one iframe
i want to do this, when user clicked on buttons, the "src" attribute of iframe change and then the content of destination loaded to iframe, and when the iframe is loading,
the loading show to user, this my asp page
 
<head id="Head1"  runat="server">
    <title></title>
 
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
 
    <style type="text/css">
        #container, #container iframe {
            position: relative;
            width: 800px;
            height: 500px;
        }
 
        #loading {
            position: absolute;
            width: 100%;
            height: 100%;
            display: none;
            background-color: rgba(160, 160, 160, 0.6);
            color: White;
            top: 0;
            right: 0;
            text-align: center;
            font-family: Tahoma;
        }
 
        #InnerLoading {
            display: none;
            color: white;
            margin-top: 200px;
        }
    </style>
 
    <script type="text/javascript">
        $(function () {
            $('a.framesLinks').click(function (){
                var frame1 = document.getElementById('frame1');
                var loadingDisplay = document.getElementById('loading').style;
                loadingDisplay.display = 'block';
                var innerLoading = document.getElementById('InnerLoading').style;
                innerLoading.display = 'block';
                if (frame1.onload == null) {
                    frame1.onload = function () {
                        loadingDisplay.display = 'none'
                        innerLoading.display = 'none'
                    };
                    if (window.attachEvent) {
                        frame1.attachEvent('onload', frame1.onload);
                    }
                }
                if (fram.onload != null) {
                    loadingDisplay.display = 'block';
                    innerLoading.display = 'block';
                }
                return true;
            });
 
        });
    </script>
 
</head>
<body>
    <form id="form1" runat="server">
 
    <table align="center">
        <tr>
            <td>
                <a class="framesLinks" href="http://www.npg.ir/net" target="frame1">ASP.NET</a>
                <a class="framesLinks" href="http://www.npg.ir/soft" target="frame1">Google</a>
                <a class="framesLinks" href="http://www.npg.ir" target="frame1">Yahoo</a>
                <div id="container">
                    <iframe class="FrameFrame" id="frame1" name="frame1" src="about:blank" scrolling="auto" frameborder="1" ></iframe>
                    <table align="center">
                        <tr>
                            <td>
                                <div id="loading">
                                    <div id="InnerLoading">
                                        <span dir="rtl">در حال بارگزاری . . .<br />
                                        </span>
                                        <img src="Loading Image.gif" alt="Loading . . ." />
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </td>
        </tr>
    </table>
    </form>
</body>

 
it's work fine, but when the iframe refresh/reload it's doesn't work
because the JavaScript function is set to the click event of linkButtons
but i'm want to shown image to user when iframe are refresh.
Posted 28-Nov-12 0:20am

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

  Print Answers RSS
0 Mika Wendelius 236
1 Abhinav S 155
2 Peter Leow 140
3 Kornfeld Eliyahu Peter 115
4 Sergey Alexandrovich Kryukov 115
0 Sergey Alexandrovich Kryukov 8,593
1 OriginalGriff 6,536
2 Peter Leow 3,727
3 Zoltán Zörgő 3,456
4 Richard MacCutchan 2,417


Advertise | Privacy | Mobile
Web03 | 2.8.150123.1 | Last Updated 28 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100