تصف هذه المقالة طريقة JavaScript لمحاكاة تنفيذ مربع تحميل Ajax ، ويتم مشاركتها معك للرجوع إليها. الطرق المحددة هي كما يلي:
نسخة الكود كما يلي: تحميل الوظيفة (p_value ، str)
{
إذا (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 ؛ // احصل على الارتفاع الفعلي في الصفحة
Top_position = Top + 157 + "PX" ؛
para.style.top = top_position ؛
icon.style.csstext += "؛ align-align: middle ؛ padding-right: 4px ؛ margin-top: -2px ؛"
para.style.csstext +=
"؛ الموقف: المطلق ؛ اليسار: 50 ٪ ؛ العرض: 140 بكسل ؛ الهامش-اليسار: -70px ؛ الارتفاع: 50px ؛ خط الذروة: 50px ؛ الحجم ، 18px ؛ النصوص النصية: ellipsis ؛ overflow: hidden ؛ whited-space: nowrap ؛ text-align: center-color: #000 ؛ 2px 2px RGBA (0،0،0،0.5) ؛ اللون: #EEE ؛ "؛
var icon = new image () ؛
icon.src = "الصور/loading1.gif" ؛ // استبدل بالمسار الفعلي هنا
document.body.appendchild (para) ؛
para.appendchild (icon) ؛
para.appendchild (para1) ؛
}
آخر
{
document.getElementById ("load_area"). style.display = "block" ؛
}
}
آخر
{
document.getElementById ("load_area"). style.display = "none" ؛
}
}
طريقة الاتصال هي كما يلي: انسخ رمز الرمز كما يلي: التحميل (صحيح ، "تحميل ...") ؛ التحميل (خطأ)
آمل أن تكون هذه المقالة مفيدة للبرمجة الواجهة على شبكة الإنترنت للجميع.