Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET jQuery IFrame
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.
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 Sergey Alexandrovich Kryukov 434
1 OriginalGriff 380
2 CHill60 240
3 Abhinav S 220
4 CPallini 220
0 Sascha Lefévre 75
1 OriginalGriff 70
2 F-ES Sitecore 55
3 Peter Leow 50
4 Dave Kreskowiak 40

Advertise | Privacy | Mobile
Web01 | 2.8.150327.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