javaScript製作彩色文字的方法!
可以用於Xoops佈景的標題文字特效製作,讓原本單色的文字顯示多種隨機的色彩。
.jpg)
1、將以下code複製起來,貼到<HEAD> 裡面 </HEAD>
<script language="JavaScript">
hexa = new MakeArray(16)
hexa[10] = "A"
hexa[11] = "B"
hexa[12] = "C"
hexa[13] = "D"
hexa[14] = "E"
hexa[15] = "F"
function MakeArray(n)
{
this.length = n
for (var i = 0; i <= n; i++)
this[i] = i
return this
}
function colours(text){
var posa = 0
var posb = 1
while (posa <= text.length){
var r = Math.floor(Math.random() * 15)
var rr= Math.floor(Math.random() * 15)
var g = Math.floor(Math.random() * 15)
var gg = Math.floor(Math.random() * 15)
var b = Math.floor(Math.random() * 15)
var bb = Math.floor(Math.random() * 15)
if (text.substring(posa,posb) == "<"){
var posaa = 0
posaa = posa
while (text.substring(posaa,posb) != ">"){
posaa++
posb++
}
document.write(text.substring(posa, posb))
posa = posb
posb = posa + 1
}
document.write("<font color=#"+hexa[r]+hexa[rr]+hexa[g]+hexa[gg]+hexa[b]+hexa[bb]+">")
document.write(text.substring(posa, posb)+"</font>")
posa++
posb++
}
}
</script>
2、將以下的code複製起來,貼到<body> 裡面裡面 </body>
<script language = "javascript"> text = "文字文字文字文字文字文字文字" colours(text) </script>
3、如果要用於Xoops佈景,可以將文字文字替換為Xoops的Smarty標籤。
<script language = "javascript">
text = "<{$block.title}>"
colours(text)
</script>
4、存檔,完成js彩色字特效的套用工作。
教學撰寫:徐嘉裕Neil hsu

02-11 Windows建站->申請網址對應...
