1. การทำข้อความหมุนรอบเมาส์
<SCRIPT LANGUAGE="JavaScript"><!-- Begin
if (document.all) {
//Things you can alter
yourLogo = "ใส่ข้อความของคุณตรงนี้"; //ห้ามน้อยกว่า 2 ตัวอักษร!
logoFont = "Tahoma";
logoColor = "000000";
//Nothing needs altering below!
yourLogo = yourLogo.split('');
L = yourLogo.length;
TrigSplit = 360 / L;
Sz = new Array()
logoWidth = 100;
logoHeight = -30;
ypos = 0;
xpos = 0;
step = 0.03;
currStep = 0;
document.write('<div id="outer" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i = 0; i < L; i++) {
document.write('<div id="ie" style="position:absolute;top:0px;left:0px;'
+'width:10px;height:10px;font-family:'+logoFont+';font-size:12px;'
+'color:'+logoColor+';text-align:center">'+yourLogo[i]+'</div>');
}
document.write('</div></div>');
function Mouse() {
ypos = event.y;
xpos = event.x - 5;
}
document.onmousemove=Mouse;
function animateLogo() {
outer.style.pixelTop = document.body.scrollTop;
for (i = 0; i < L; i++) {
ie[i].style.top = ypos + logoHeight * Math.sin(currStep + i * TrigSplit * Math.PI / 180);
ie[i].style.left = xpos + logoWidth * Math.cos(currStep + i * TrigSplit * Math.PI / 180);
Sz[i] = ie[i].style.pixelTop - ypos;
if (Sz[i] < 5) Sz[i] = 5;
ie[i].style.fontSize = Sz[i] / 1.7;
}
currStep -= step;
setTimeout('animateLogo()', 20);
}
window.onload = animateLogo;
}
// End -->
</script>
นำโค้ดด้านบนไปวางตรงส่วน BODY
2.ทำกรอบข้อความ หรือว่ารูปภาพกระพริบเป็นสีๆ
<table border="0" width="280" id="myexample" style="border:5px solid yellow">
<tr>
<td align="center"><font face="MS Sans Serif" size="1">ตรงนี้คุณจะใส่รูปหรือตัวอักษรอะไรก็ได้ครับ</font><br></td>
</tr>
</table>
<script language="JavaScript1.2">
function flashit(){
if (!document.all)
return
if (myexample.style.borderColor=="yellow")
myexample.style.borderColor="lime"
else
myexample.style.borderColor="yellow"
}
setInterval("flashit()", 500)
//-->
</script>
<tr>
<td align="center"><font face="MS Sans Serif" size="1">ตรงนี้คุณจะใส่รูปหรือตัวอักษรอะไรก็ได้ครับ</font><br></td>
</tr>
</table>
<script language="JavaScript1.2">
function flashit(){
if (!document.all)
return
if (myexample.style.borderColor=="yellow")
myexample.style.borderColor="lime"
else
myexample.style.borderColor="yellow"
}
setInterval("flashit()", 500)
//-->
</script>
นำโค้ดด้านบนไปวางตรงส่วน BODY
3.ทำตัวอักษรเปลี่ยนสีทีละตัว เหมือนเพลงคาราโอเกะ
<script language="JavaScript1.2">
var message="พิมพ์ข้อความที่นี่ครับ"
var neonbasecolor="gray"
var neontextcolor="yellow"
var flashspeed=100 //in milliseconds
///No need to edit below this line/////
var n=0
if (document.all){
document.write('<font color="'+neonbasecolor+'">')
for (m=0;m<message.length;m++)
document.write('<span id="neonlight">'+message.charAt(m)+'</span>')
document.write('</font>')
//cache reference to neonlight array
var tempref=document.all.neonlight
}
else
document.write(message)
function neon(){
//Change all letters to base color
if (n==0){
for (m=0;m<message.length;m++)
tempref[m].style.color=neonbasecolor
}
//cycle through and change individual letters to neon color
tempref[n].style.color=neontextcolor
if (n<tempref.length-1)
n++
else{
n=0
clearInterval(flashing)
setTimeout("beginneon()",1500)
return
}
}
function beginneon(){
if (document.all)
flashing=setInterval("neon()",flashspeed)
}
beginneon()
</script>
นำโค้ดด้านบนไปวางตรงส่วน BODY
ไม่มีความคิดเห็น:
แสดงความคิดเห็น