تصف هذه المقالة طريقة تنفيذ JS لتوسيع نوافذ الويب من الوسط إلى الأعلى والأسفل. شاركه للرجوع إليه. التحليل المحدد هو كما يلي:
يتم عرض هذه الصفحة من الوسط وتتوسع ببطء لأعلى ولأسفل ، وهو أمر غير سيء ، فإن الكود كما يلي:
انسخ الرمز كما يلي: <html>
<head>
<title> يعرض JS نافذة الويب الخاصة بالوسط الموسع </title>
<style>
<!-
.intro {
الموقف: مطلق ؛
اليسار: 0 ؛
أعلى: 0 ؛
طبقة الخلفية اللون: أصفر.
لون الخلفية:#336699 ؛
الحدود: 0.1px الصلبة #336699
}
->
</style>
</head>
<body>
<div id = "i1"> </viv> <div id = "i2"> </viv>
<script language = "javaScript1.2">
var speed = 20
var temp = new array ()
var temp2 = new array ()
if (document.layers) {
لـ (i = 1 ؛ i <= 2 ؛ i ++) {
temp [i] = eval ("document.i"+i+". clip")
temp2 [i] = eval ("document.i"+i)
درجة الحرارة [i] .width = window.innerwidth
درجة الحرارة [i] .hight = window.innerheight/2
temp2 [i] .top = (i-1)*temp [i]. height
}
}
آخر إذا (document.all) {
var clipbottom = document.body.offsetheight/2 ، cliptop = 0
لـ (i = 1 ؛ i <= 2 ؛ i ++) {
temp [i] = eval ("document.all.i"+i+". style")
temp [i] .width = document.body.clientwidth
temp [i]. height = document.body.offsetheight/2
Temp [i] .top = (I-1)*parseint (temp [i]. home)
}
}
وظيفة OpenIt () {
window.scrollto (0،0)
if (document.layers) {
درجة الحرارة [1] .bottom- = السرعة
درجة الحرارة [2] .Top+= السرعة
إذا (temp [1] .bottom <= 0)
ClearInterval (StopIt)
}
آخر إذا (document.all) {
clipbottom- = السرعة
temp [1] .clip = "Rect (0 Auto+"+ClipBottom+"0)"
cliptop+= السرعة
temp [2] .clip = "rect ("+cliptop+"Auto Auto)"
إذا (clipbottom <= 0)
ClearInterval (StopIt)
}
}
وظيفة gogo () {
StopIt = setInterval ("OpenIt ()" ، 100)
}
gogo ()
</script>
</body>
</html>
آمل أن تكون هذه المقالة مفيدة لبرمجة اللغة GO للجميع.