JavaScript & Dynamic HTML 

文字列の色を一定時間毎に変化させます。


☆★☆★☆★ 文字列の色が変ります ☆★☆★☆★


表示で『ソース』がご覧いただけます。
<HTML>
<HEAD>

<SCRIPT Language="JavaScript">
<!--
if(navigator.appVersion.charAt(0)>=4 && (navigator.appVersion).indexOf("MSIE")!=-1)
isIE4 = true; else isIE4 = false; function random_color() { var col=new String(); for(i=0;i<3;i++) { ran = Math.floor(Math.random()*255); ran = ran.toString(16); ran_len = ran.length; if(ran_len<2) ran = "0"+ran; col += ran; } return col; } function textAnima_color1(id,n) { el = document.all.item(id,n); col = random_color(); el.style.color = "#"+col; getT = el.getAttribute("Set_time"); if(getT=="") getT=100; setTimeout("textAnima_color1('"+id+"',"+n+")",getT); } if(isIE4) { window.onload = init; } function init() { id = "Anima_text_color"; len = document.all.item(id).length; if(!len) len = 1; for(var i=0; i<len; i++) { textAnima_color1(id,i); } } //--> </SCRIPT>
</HEAD> <BODY> <center> <b> <span style="font-size:20pt" id="Anima_text_color" Set_time="100"> 『ここに色を変化させたい文字列を入れます』 </span> </b> </center> </BODY> </HTML>
上記の赤色の部分で囲まれた部分に対してアニメーションを行います。
同じアニメーションを行うタグのidは全部共通にして下さい。
指定の id がない場合はエラーが出るのでご注意下さい。
(例)<b id="Anima_text_color" Set_time="500">ABCD</b>

Set_time=は、アニメーションのスピードの調整です。数字が小さいほど早くなります。

Top Page   Back
inserted by FC2 system