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

    <script type="text/javascript" src=""></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;

    <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;


    <form id="form1" runat="server">

    <table align="center">
                <a class="framesLinks" href="" target="frame1">ASP.NET</a>
                <a class="framesLinks" href="" target="frame1">Google</a>
                <a class="framesLinks" href="" 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">
                                <div id="loading">
                                    <div id="InnerLoading">
                                        <span dir="rtl">در حال بارگزاری . . .<br />
                                        <img src="Loading Image.gif" alt="Loading . . ." />

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.

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