C# 是否显示动画gif文件,直到asp页面加载并重定向?

C# 是否显示动画gif文件,直到asp页面加载并重定向?,c#,jquery,html,asp.net,C#,Jquery,Html,Asp.net,当我单击重定向按钮时,asp.net project重定向一个html文件,并向用户显示一个加载程序(动画gif)。然后它重定向到特定页面。它很好用 但现在我不需要中间重定向页面。当我单击重定向按钮时,它会显示特定的asp页面,加载程序(动画gif)会在同一页面中显示中心,直到加载为止。加载页面后,加载程序(动画gif)必须隐藏。我该怎么做?。给一个样品 C#代码- Response.Redirect("Redirecting.html?AvailResults.aspx"); <bod

当我单击重定向按钮时,asp.net project重定向一个html文件,并向用户显示一个加载程序(动画gif)。然后它重定向到特定页面。它很好用

但现在我不需要中间重定向页面。当我单击重定向按钮时,它会显示特定的asp页面,加载程序(动画gif)会在同一页面中显示中心,直到加载为止。加载页面后,加载程序(动画gif)必须隐藏。我该怎么做?。给一个样品

C#代码-

Response.Redirect("Redirecting.html?AvailResults.aspx");
<body>
<div style='position:absolute;z-index:5;top:45%;left:45%;'>
    <img id="imgAjax" alt="loading..." title="loading..." src="images/ajax-loading.gif" style="width: 100px; height: 100px" /><br /> <br />
 </div>

<script type="text/javascript">
    /* <![CDATA[ */
    this.focus(); //focus on new window

    redirect = function() {
        var querystring = window.location.search.substring(1); //first query string
        var page = querystring.substring(querystring.indexOf('=') + 1, querystring.length);
        function toPage() {
            if (page !== undefined && page.length > 1) {
                document.write('<!--[if !IE]>--><head><meta http-equiv="REFRESH" content="1;url=' + page + '" /><\/head><!--<![endif]-->');
                document.write(' \n <!--[if IE]>');
                document.write(' \n <script type="text/javascript">');
                document.write(' \n var version = parseInt(navigator.appVersion);');
                document.write(' \n if (version>=4 || window.location.replace) {');
                document.write(' \n window.location.replace("' + page + '");');
                document.write(' document.images["imgAjax"].src = "images/ajax-loading.gif"');
                document.write(' \n } else');
                document.write(' \n window.location.href="' + page + '";');
                document.write(' \n  <\/script> <![endif]-->');
            }
        }
        return {
            begin: toPage
        }
    } ();

    redirect.begin();

    /* ]]> */
</script>  
</body>
Redirecting.html代码-

Response.Redirect("Redirecting.html?AvailResults.aspx");
<body>
<div style='position:absolute;z-index:5;top:45%;left:45%;'>
    <img id="imgAjax" alt="loading..." title="loading..." src="images/ajax-loading.gif" style="width: 100px; height: 100px" /><br /> <br />
 </div>

<script type="text/javascript">
    /* <![CDATA[ */
    this.focus(); //focus on new window

    redirect = function() {
        var querystring = window.location.search.substring(1); //first query string
        var page = querystring.substring(querystring.indexOf('=') + 1, querystring.length);
        function toPage() {
            if (page !== undefined && page.length > 1) {
                document.write('<!--[if !IE]>--><head><meta http-equiv="REFRESH" content="1;url=' + page + '" /><\/head><!--<![endif]-->');
                document.write(' \n <!--[if IE]>');
                document.write(' \n <script type="text/javascript">');
                document.write(' \n var version = parseInt(navigator.appVersion);');
                document.write(' \n if (version>=4 || window.location.replace) {');
                document.write(' \n window.location.replace("' + page + '");');
                document.write(' document.images["imgAjax"].src = "images/ajax-loading.gif"');
                document.write(' \n } else');
                document.write(' \n window.location.href="' + page + '";');
                document.write(' \n  <\/script> <![endif]-->');
            }
        }
        return {
            begin: toPage
        }
    } ();

    redirect.begin();

    /* ]]> */
</script>  
</body>



/* 1) { 文件。写(“”); document.write('\n'); } } 返回{ 开始:toPage } } (); 重定向。开始(); /* ]]> */
这里的问题是,您无法删除中间步骤并在不同的url上显示/隐藏微调器(加载微调器时,您可能已经重定向了它)。您需要一个页面来加载ajax微调器。我看到两种选择:

选项1:返回到原来的方式(单击重定向按钮,使用微调器转到重定向页面,然后重定向到最终目标)。这类似于论坛经常使用的“你现在离开xyz.com”启动页面

选项2:将iFrame添加到重定向页面中,以便可以同时显示/隐藏微调器和加载目标页面(在iFrame中)。(如果你在应用程序中重定向到自己的页面或保持主机不变,你应该能够避免跨站点问题,并确保目标页面不包含框架突破脚本等)

下面是可能的情况:

<div style='position:absolute;z-index:5;top:45%;left:45%;'>
  <img id="imgAjax" alt="loading..." title="loading..." src="images/ajax-loading.gif" style="width: 100px; height: 100px" />
</div>

<iframe src="about:blank" id="ifRedir" onload="$('#imgAjax').hide();" style="width:100%;height:100%;border:0px;"</iframe>

<script type="text/javascript">
    $(document).ready(function () {
        $('#ifRedir').attr('src', location.search.substr(1));
    });
</script>  


这个代码看起来很古老!检查IE4!那是在90年代出现的