บทความนี้อธิบายวิธีการใช้งาน JS เพื่อขยายหน้าต่างเว็บจากกลางถึงด้านบนและล่าง แบ่งปันสำหรับการอ้างอิงของคุณ การวิเคราะห์เฉพาะมีดังนี้:
หน้านี้จะแสดงจากกลางและค่อยๆขยายขึ้นและลงซึ่งไม่เลวรหัสมีดังนี้:
คัดลอกรหัสดังนี้: <html>
<head>
<title> js แสดงหน้าต่างเว็บของ Middle ที่ขยายตัว </title>
<style>
-
.intro {
ตำแหน่ง: สัมบูรณ์;
ซ้าย: 0;
ด้านบน: 0;
ชั้นหลังพื้นหลัง: สีเหลือง;
พื้นหลังสี:#336699;
ชายแดน: 0.1px Solid #336699
-
-
</style>
</head>
<body>
<div id = "i1"> </div> <div id = "i2"> </div>
<ภาษาสคริปต์ = "JavaScript1.2">
var speed = 20
var temp = อาร์เรย์ใหม่ ()
var temp2 = อาร์เรย์ใหม่ ()
if (document.layers) {
สำหรับ (i = 1; i <= 2; i ++) {
Temp [i] = eval ("document.i"+i+". clip")
temp2 [i] = eval ("document.i"+i)
temp [i] .width = window.innerWidth
temp [i] .height = 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
temp [i] .width = document.body.clientwidth
temp [i] .height = document.body.offsetheight/2
temp [i] .top = (i-1)*parseint (temp [i] .Height)
-
-
ฟังก์ชั่น openit () {
window.scrollto (0,0)
if (document.layers) {
Temp [1] .Bottom- = ความเร็ว
อุณหภูมิ [2] .top+= ความเร็ว
if (temp [1] .bottom <= 0)
ClearInterval (หยุด)
-
อื่นถ้า (document.all) {
Clipbottom- = ความเร็ว
temp [1] .clip = "rect (0 auto+"+clipbottom+"0)"
CLIPTOP+= ความเร็ว
temp [2] .clip = "rect ("+cliptop+"auto auto)"
if (clipbottom <= 0)
ClearInterval (หยุด)
-
-
ฟังก์ชั่น gogo () {
StopIt = SetInterval ("OpenIt ()", 100)
-
Gogo ()
</script>
</body>
</html>
ฉันหวังว่าบทความนี้จะเป็นประโยชน์กับการเขียนโปรแกรมภาษาของทุกคน