圖片亂數取得

edited 十月 2013 in Javascript
請問我要在某個框框用Javascript去讀取圖片
以下是拷貝別人的語法,可否協助該如何置入呢?
@"

<script language="JavaScript1.1">

//Picture Cube slideshow - By Tony Foster III
//Modifications by JK
//Visit JavaScript Kit (http://javascriptkit.com) for script

var specifyimage=new Array() //Your images
specifyimage[0]="../img_lib/11813754540.jpg"
specifyimage[1]="../img_lib/11813754541.jpg"
specifyimage[2]="../img_lib/11813754542.jpg"
specifyimage[3]="../img_lib/11813754543.jpg"

var delay=3000 //3 seconds

//Counter for array
var count =1;

var cubeimage=new Array()
for (i=0;i<specifyimage.length;i++){
cubeimage=new Image()
cubeimage.src=specifyimage
}

function movecube(){
if (window.createPopup)
cube.filters[0].apply()
document.images.cube.src=cubeimage[count].src;
if (window.createPopup)
cube.filters[0].play()
count++;
if (count==cubeimage.length)
count=0;
setTimeout("movecube()",delay)
}

window.onload=new Function("setTimeout('movecube()',delay)")
</script>

<img src="../img_lib/11813754540.jpg" name="cube" style="filter:progid:DXImageTransform.Microsoft.Stretch(stretchStyle='PUSH')" border="0">



原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=6677

評論

  • edited 六月 2012
    <script type="text/javascript"><!--
    yudan_pic = new Array(4);
    yudan_pic[0] = "圖片網址1";
    yudan_pic[1] = "圖片網址2";
    yudan_pic[2] = "圖片網址3";
    yudan_pic[3] = "圖片網址4";
    index = Math.floor(Math.random() * yudan_pic.length);
    document.write('<img src="' +yudan_pic[index]+ '" alt="" />');
    // --></script>

    @"
Sign In or Register to comment.