65.9K
CodeProject is changing. Read more.
Home

Full Screen Loading Panel

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Oct 11, 2013

CPOL
viewsIcon

6720

After few projects, finally come out with this simple loading panel scripts. Hope it useful for your.JavaScripts  function ShowLoading() {

After few projects, finally come out with this simple loading panel scripts. Hope it useful for your.

JavaScripts 

 function ShowLoading() {

 
    function GetWidth() {
        var x = 0;
        if (self.innerWidth) {
            x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientWidth) {
            x = document.documentElement.clientWidth;
        }
        else if (document.body) {
            x = document.body.clientWidth;
        }
        return x;
    };
 
    function GetHeight() {
        var y = 0;
        if (self.innerHeight) {
            y = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight) {
            y = document.documentElement.clientHeight;
        }
        else if (document.body) {
            y = document.body.clientHeight;
        }
        return y;
    };
 
    $("body").append("<div class='LsnLoadingPanelFade'></div><img style='top:" + (GetHeight() / 2).toString() + "px; left:" + (GetWidth() / 2).toString() + "px' class='LsnLoadingPanel'/>");
};
 
function HideLoading() {
    $(".LsnLoadingPanelFade").remove();
    $(".LsnLoadingPanel").remove();
};
 Css Class
.LsnLoadingPanelFade 
{
 	positionfixed;
	width100%;
	height100%;
	top0;
	left0;
	z-index:99999;
}
 
.LsnLoadingPanel 
{
	positionfixed;
	z-index:100000;
	background-image:url('../Images/Loading.gif');
	width:106px;
	height:54px
} 

   These sample scripts must work together with jQuery. E.g.

<head runat="server">
    <title></title>
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/Scripts/jquery-1.4.1.min.js"></script>
</head>
So that, your can simply inject below script and a full screen loading panel will poped up. Enjoy & happy coding.
ShowLoading();