این اسکریپت موجب خواهد شد که حروف یک کلمه ابتدا تک تک به نمایش درآید سپس تکمیل گردد. این اسکریپت جزوء اولین اسکریپتهای در این زمینه میباشد به مرور اسکریپتهایی با همین کاربرد ولی به گونه ای دیگر ارائه خواهد شد.
<html>
<body>
<script language=”JavaScript”>
<!–
// please keep these lines on when you copy the source
// made by: Amir – http://www.iranjavascript.com
var current = 0
var x = 0
var speed = 100
var speed2 = 4000
function initArray(n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ‘ ‘
}
}
action = new initArray(4)
action[0]=”This is Message 1″
action[1]=”Now it is Message 2″
action[2]=”No, do not say I have to do 3 messages”
action[3]=”Yea, this message, 4, is the last message (and it’s long)”
function action2() {
var m = action[current]
window.status = m.charAt(x++)
if (x == m.length + 1) {
x = 0
current++
window.status = m
if (current > action.length – 1) {
current = 0
}
setTimeout(“action2()”, speed2)
}
else {
setTimeout(“action2()”, speed)
}
}
action2()
//–>
</script>
<h2>IranJavaScript.com</h2>
</body>
</html>
دیدگاه خود را بیان کنید.
باید وارد سایت شده باشید برای دیدگاه دادن