在现有的javascript中链接旋转图像

时间:2015-06-04 01:00:51

标签: javascript

自从我将我的治疗挖到JS后可以使用一些帮助已经有一段时间了。希望修改此现有脚本以包含每个旋转图像的链接...想要将名为“text”的对象链接到每个图像的相同URL。任何想法?

//cur_index = 1;
cur_index = Math.floor(Math.random()*6);
//var randomnumber=Math.floor(Math.random()*11)
num_image = 5;
//alert(cur_index);
interval  = 300000; // 5min between rotations
function rotate(){
   // if(cur_index > num_image)
   //    cur_index = 1;
        if(cur_index == 0)
       cur_index = 1;
    var imag,text;
    if(document.getElementById){
        imag = document.getElementById("faceImage");
        text = document.getElementById("faceText");
    }else if(document.all) {        
        imag = document.all["faceImage"];
        text = document.all["faceText"];
    }else if(document.layers){
        imag = document.layers["faceImage"];
        text = document.layers["faceText"];
    }

    var imageUrl = "/path/face" + cur_index + ".jpg";
    var textUrl = "/path/face" + cur_index + "_text.gif";
    imag.src = imageUrl;
    text.src = textUrl;
    //cur_index++;
    cur_index = Math.floor(Math.random()*6);
    setTimeout('rotate()',interval);
}

0 个答案:

没有答案