TOP /すぐに使えるJavaScript 動くバナー








<script type="text/javascript"><!--
ImgSrc=new Array("himajin.gif","ickna.gif","pb2.gif","yakata2.gif","bbs_banner00.gif");  //画像のアドレス
LinkSrc=new Array("http://himajin.moo.jp/","#","#","#","#");            //リンク先アドレス
//画像のアドレスとリンク先のアドレスは、必ず対にする(リンクしないときは#を入れておく)
Imgtop=100;                      //上からの表示位置
Imgleft=0;                       //横の表示位置(0でセンター)
Wid=250;                         //回転の幅
ImgH=31;                         //画像の高さ
ImgW=88;                         //画像の幅
henpei=15;                       //扁平の度合い1で正円
imgsec=150;                      //移動速度
//----------------------------------------------------------------
for(i=0;i<ImgSrc.length;i++){
document.write("<img src='"+ImgSrc[i]+"'ID='Imglink"+i+"'STYLE='position:absolute;z-index:3;cursor:hand;width:"+ImgW+"px;height:"+ImgH+"px;'");
document.write("onMouseover='chck=1;'onMouseout='chck=0;'onclick=\"location.href='"+LinkSrc[i]+"'\">");
}
kaku=0;chck=0;imgkaku=0;
if(!Imgleft)
stX=(document.all)?document.body.clientWidth/2:window.outerWidth/2;
else
stX=Imgleft;
function LinkImg(){
if(!chck){
for(i=0;i<ImgSrc.length;i++){
pointY = Imgtop + Math.floor(Math.sin(kaku+imgkaku)*Wid/henpei);
pointX = stX-ImgW/2 + Math.floor(Math.cos(kaku+imgkaku)*Wid);
document.images["Imglink"+i].style.zIndex=(pointY<Imgtop)?2:3;
if(document.all){
document.images["Imglink"+i].style.pixelTop=pointY;
document.images["Imglink"+i].style.pixelLeft=pointX;}
else{
document.images["Imglink"+i].style.top=pointY+"px";
document.images["Imglink"+i].style.left=pointX+"px";}
imgkaku+=Math.PI*2/ImgSrc.length;imgkaku%=Math.PI*2;
}
kaku+=0.1;kaku%=Math.PI*2;imgkaku=0;
}}
onresize= function(){
if(!Imgleft)
stX=(document.all)?document.body.clientWidth/2:window.outerWidth/2;}
setInterval('LinkImg()',imgsec);/* himajin.moo.jp */
// --></script>