Click here to Skip to main content
15,883,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

ASP.NET
<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

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