javascript模擬實(shí)現(xiàn)ajax加載框?qū)嵗?/h1>
更新時(shí)間:2014年10月15日 14:44:19 投稿:shichen2014
這篇文章主要介紹了javascript模擬實(shí)現(xiàn)ajax加載框的方法,實(shí)例簡(jiǎn)述了其實(shí)現(xiàn)過(guò)程,方法簡(jiǎn)單實(shí)用,需要的朋友可以參考下
本文實(shí)例講述了javascript模擬實(shí)現(xiàn)ajax加載框的方法,分享給大家供大家參考。具體方法如下:
復(fù)制代碼 代碼如下:function loading(p_value,str)
{
if (p_value)
{
if (!document.getElementById("load_area"))
{
var para1 = document.createElement("span");
var node=document.createTextNode(str);
para1.appendChild(node);
var para=document.createElement("div");
para.id="load_area";
var top=document.body.scrollTop+document.documentElement.scrollTop;//獲取頁(yè)面中的實(shí)際高度
top_position = top+157 + "px";
para.style.top =top_position;
icon.style.cssText += ";vertical-align:middle;padding-right:4px;margin-top:-2px;"
para.style.cssText +=
";position:absolute;left:50%;width:140px;margin-left:-70px;height:50px;line-height:50px;font-size:18px;text-overflow:ellipsis;overflow:hidden; white-space:nowrap;text-align:center;background-color: #000;border-radius:2px;-webkit-box-shadow:0 2px 2px rgba(0,0,0,0.5);color:#eee;";
var icon = new Image();
icon.src="images/loading1.gif";//這里用實(shí)際路徑替換
document.body.appendChild(para);
para.appendChild(icon);
para.appendChild(para1);
}
else
{
document.getElementById("load_area").style.display="block";
}
}
else
{
document.getElementById("load_area").style.display="none";
}
}
調(diào)用方法如下:
復(fù)制代碼 代碼如下:loading(true,"加載中..."); loading(false)
希望本文所述對(duì)大家的web前端程序設(shè)計(jì)有所幫助。
相關(guān)文章
-
js實(shí)現(xiàn)動(dòng)態(tài)改變r(jià)adio狀態(tài)的方法
下面小編就為大家分享一篇js實(shí)現(xiàn)動(dòng)態(tài)改變r(jià)adio狀態(tài)的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧 2018-02-02
-
使用Object.defineProperty實(shí)現(xiàn)簡(jiǎn)單的js雙向綁定
這篇文章主要介紹了使用Object.defineProperty實(shí)現(xiàn)簡(jiǎn)單的js雙向綁定的相關(guān)資料,需要的朋友可以參考下 2016-04-04
-
JS動(dòng)態(tài)創(chuàng)建Table,Tr,Td并賦值的具體實(shí)現(xiàn)
這篇文章介紹了JS動(dòng)態(tài)創(chuàng)建Table,Tr,Td并賦值的具體實(shí)現(xiàn),有需要的朋友可以參考一下 2013-07-07
-
JavaScript控制listbox列表框的項(xiàng)目上下移動(dòng)的方法
這篇文章主要介紹了JavaScript控制listbox列表框的項(xiàng)目上下移動(dòng)的方法,實(shí)例分析了javascript操作listbox列表框的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下 2015-03-03
-
超級(jí)標(biāo)簽之一鍵解除網(wǎng)頁(yè)復(fù)制限制、網(wǎng)頁(yè)自由編輯、顯示星號(hào)密碼功能代碼
實(shí)現(xiàn)以上功能不用安裝任何插件,把下列書簽圖標(biāo)拖動(dòng)到瀏覽器書簽欄,就可以實(shí)現(xiàn)一鍵解除網(wǎng)頁(yè)復(fù)制限制、網(wǎng)頁(yè)自由編輯、顯示星號(hào)密碼功能 2022-09-09
最新評(píng)論
本文實(shí)例講述了javascript模擬實(shí)現(xiàn)ajax加載框的方法,分享給大家供大家參考。具體方法如下:
{
if (p_value)
{
if (!document.getElementById("load_area"))
{
var para1 = document.createElement("span");
var node=document.createTextNode(str);
para1.appendChild(node);
var para=document.createElement("div");
para.id="load_area";
var top=document.body.scrollTop+document.documentElement.scrollTop;//獲取頁(yè)面中的實(shí)際高度
top_position = top+157 + "px";
para.style.top =top_position;
icon.style.cssText += ";vertical-align:middle;padding-right:4px;margin-top:-2px;"
para.style.cssText +=
";position:absolute;left:50%;width:140px;margin-left:-70px;height:50px;line-height:50px;font-size:18px;text-overflow:ellipsis;overflow:hidden; white-space:nowrap;text-align:center;background-color: #000;border-radius:2px;-webkit-box-shadow:0 2px 2px rgba(0,0,0,0.5);color:#eee;";
var icon = new Image();
icon.src="images/loading1.gif";//這里用實(shí)際路徑替換
document.body.appendChild(para);
para.appendChild(icon);
para.appendChild(para1);
}
else
{
document.getElementById("load_area").style.display="block";
}
}
else
{
document.getElementById("load_area").style.display="none";
}
}
調(diào)用方法如下:
希望本文所述對(duì)大家的web前端程序設(shè)計(jì)有所幫助。
相關(guān)文章
js實(shí)現(xiàn)動(dòng)態(tài)改變r(jià)adio狀態(tài)的方法
下面小編就為大家分享一篇js實(shí)現(xiàn)動(dòng)態(tài)改變r(jià)adio狀態(tài)的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-02-02使用Object.defineProperty實(shí)現(xiàn)簡(jiǎn)單的js雙向綁定
這篇文章主要介紹了使用Object.defineProperty實(shí)現(xiàn)簡(jiǎn)單的js雙向綁定的相關(guān)資料,需要的朋友可以參考下2016-04-04JS動(dòng)態(tài)創(chuàng)建Table,Tr,Td并賦值的具體實(shí)現(xiàn)
這篇文章介紹了JS動(dòng)態(tài)創(chuàng)建Table,Tr,Td并賦值的具體實(shí)現(xiàn),有需要的朋友可以參考一下2013-07-07JavaScript控制listbox列表框的項(xiàng)目上下移動(dòng)的方法
這篇文章主要介紹了JavaScript控制listbox列表框的項(xiàng)目上下移動(dòng)的方法,實(shí)例分析了javascript操作listbox列表框的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-03-03超級(jí)標(biāo)簽之一鍵解除網(wǎng)頁(yè)復(fù)制限制、網(wǎng)頁(yè)自由編輯、顯示星號(hào)密碼功能代碼
實(shí)現(xiàn)以上功能不用安裝任何插件,把下列書簽圖標(biāo)拖動(dòng)到瀏覽器書簽欄,就可以實(shí)現(xiàn)一鍵解除網(wǎng)頁(yè)復(fù)制限制、網(wǎng)頁(yè)自由編輯、顯示星號(hào)密碼功能2022-09-09