この記事の例では、ajax ローディング ボックスを実装するための JavaScript シミュレーションの方法を説明し、参考のために皆さんと共有します。具体的な方法は以下の通りです。
functionloading(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="ロードエリア";
var top=document.body.scrollTop document.documentElement.scrollTop;//ページの実際の高さを取得します
top_position = 上位 157 "ピクセル";
para.style.top =top_position;
icon.style.cssText = ";vertical-align:middle;padding-right:4px;margin-top:-2px;"
para.style.cssText =
";位置:絶対;左:50%;幅:140px;左マージン:-70px;高さ:50px;行の高さ:50px;フォントサイズ:18px;テキストオーバーフロー:省略記号;オーバーフロー:非表示;白-スペース: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";//ここで
を実際のパスに置き換えます
document.body.appendChild(para);
para.appendChild(icon);
para.appendChild(para1);
}
それ以外
{
document.getElementById("load_area").style.display="ブロック";
}
}
それ以外
{
document.getElementById("load_area").style.display="none";
}
}