|
 |
|
ถามเรื่องการหน่วงเวลาของ javascript หน่อยครับ โค้ดนี้ผมทำมาแบบลวกๆ แตกฟังก์ชันย่อยๆออกไป |
|
 |
|
|
 |
 |
|
วิธีน่ะมีครับ ขอทราบความต้องการหน่อยครับ จะได้บอกถูกนะ อ่านโค้ดไม่เข้าใจอ่ะว่าคุณต้องการจะทำอะไร
|
 |
 |
 |
 |
Date :
2009-10-11 15:26:13 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ต้องการทำ loading image ครับ
พอกด button ให้ปรากฏภาพ แล้วหน่วงเวลาไป 5 วิ หลังจากนั้นก็ทำให้ภาพหายไป
|
 |
 |
 |
 |
Date :
2009-10-11 15:37:37 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้ว โค้ดของคุณมันมีปัญหาอะไรเหรอคับ
|
 |
 |
 |
 |
Date :
2009-10-11 15:41:45 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เปล่าครับ 
แต่อยากได้วิธีอื่นๆ อ่ะครับ อันนี้มันไม่ค่อยดีอ่ะครับ มันมีฟังก์ชันแยกย่อยเยอะไปหน่อย
พี่เอี่ยวพอจะมีแบ่งปันบ้างไมครับ :>  
|
 |
 |
 |
 |
Date :
2009-10-11 15:53:19 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แหล่ะครับ
ผมเขียนผิดวิธีเอง
ขอโทษทีน่ะครับที่รบกวนพี่เอี่ยว 
|
 |
 |
 |
 |
Date :
2009-10-11 16:06:04 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ว่าแต่ ทำไมต้องเรียกตัวเองด้วยล่ะครับ
t=setTimeout("timedCount("+(ms-1)+")",1000);
timedCount(5); บรรทัดนี้น่าจะเรียก setTimeout('stop', 5000); เลยไม่ดีเหรอไงคับ
หรือว่าคุณต้องการจะคำนวน ทุกช่วงเวลาในเวลา 5 วิอีกที
ถ้าแบบนั้นก็น่าจะใช้ window.setInterval() นะครับ
|
 |
 |
 |
 |
Date :
2009-10-11 16:07:58 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
555+
ตรงนี้แหละที่ผมเขียนผิดวิธี งงกับตัวเองเหมือนกันทำอะไรอยู่
แก้เรียบร้อยแล้วครับ
window.setInterval() น่าใช้แห่ะ
ขอบคุณพี่เอี่ยวครับ ได้ฟังก์ชันใหม่ๆมาอีกหนึ่งฟังก์ชัน  
|
 |
 |
 |
 |
Date :
2009-10-11 16:54:53 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวนี้ใช้ยากหน่อยนะ window.setInterval();
ผมใช้เวลาเอาไว้ปล่อย Thread มันมีรายละเอียดหน่อยนึงเวลาจะสั่งหยุดหรือเดินต่อ แต่ก็ใช้ได้โอเค ถ้าใช้ไม่เป็น บราวเซอร์ อาจแฮ้งได้นะครับ 
|
 |
 |
 |
 |
Date :
2009-10-11 17:07:56 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยินดีด้วย แต่ห้ามแก้ผ้าแถวนี้นะ
|
 |
 |
 |
 |
Date :
2009-10-11 17:08:09 |
By :
danya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|