javascript - Redirect to page with loading animation - Stack Overflow

I already know this solution. (transfer the slow loading page to a loading-interim-page which shows the

I already know this solution. (transfer the slow loading page to a loading-interim-page which shows the animation and then redirects to the actual page)

But I would really like to solve this without a redirecting page. Any clue how ? The redirect will be triggered from codebehind...

I already know this solution. (transfer the slow loading page to a loading-interim-page which shows the animation and then redirects to the actual page)

But I would really like to solve this without a redirecting page. Any clue how ? The redirect will be triggered from codebehind...

Share Improve this question edited Aug 17, 2010 at 15:10 dll32 asked Aug 17, 2010 at 15:04 dll32dll32 2352 gold badges4 silver badges15 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

You could try something like this:

<head>
...
<script type="text/javascript">
    if (document.documentElement) {
        document.documentElement.className = 'loading';
    }
</script>
...
</head>

Stick that in your <head> tag, then add some CSS to hide everything on the page except for your loading animation. For example:

.loading > body > * {
    display:none;
}
.loading body {
    background:#fff url(../images/loading.gif) no-repeat 50% 50%;
}

Then add some JavaScript to clear the html tag's class name when the page has finished loading:

// Using jQuery
$(document).ready(function() {
    ...
    $(document.documentElement).removeClass('loading');
    ...
});

Hope this helps.

Here is an example with jQuery.
http://pure-essence/2010/01/29/jqueryui-dialog-as-loading-screen-replace-blockui/

And one more simple
http://javascript.internet./css/pre-loading-message.html

You may see Example This by following this link http://onlineshoping.somee./ This is very easy way to display loading animation, while page is loading each time.

protected void Page_Load(object sender, EventArgs e)
{
        if (this.IsPostBack)
        {

        }
        else
        {
            Response.Write("<div id=\"loading\" style=\" text-align:center; top:100px;\"><p> Please Wait...</p><br/><img src=\"../Your Animation .gif file path\" \"width:400px\"></div>");
            Response.Flush();
            System.Threading.Thread.Sleep(5000);//You may increase Or decrees Thread Sleep time 
            Response.Write("<script>document.getElementById('loading').style.display='none';</script>");
        }
}

You may download ajax custom animation .gif file from this web site http://ajaxload.info/
I hope it will solve your problem.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742419002a4440304.html

相关推荐

  • javascript - Redirect to page with loading animation - Stack Overflow

    I already know this solution. (transfer the slow loading page to a loading-interim-page which shows the

    19小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信