新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
JavaScript中圖像處理技巧
你知道JavaScript中如何對(duì)圖像進(jìn)行操作嗎,這里和大家簡(jiǎn)單分享一下,希望通過本文的詳細(xì)介紹你對(duì)JavaScript中圖像的操作有明確的認(rèn)識(shí)。

JavaScript圖像
讀取圖像屬性
- 1
- 2
- onClick=”window.alert(document.myImage.width)”>
- Width
動(dòng)態(tài)加載圖像
- 1
- 2myImage=newImage;
- 3myImage.src=“Tellers1.jpg”;
- 4
簡(jiǎn)單的圖像替換
- 1
- 2rollImage=newImage;
- 3rollImage.src=“rollImage1.jpg”;
- 4defaultImage=newImage;
- 5defaultImage.src=“image1.jpg”;
- 6
- 7
- ”onMouseOver=”document.myImage.src=rollImage.src;”
- 8onMouseOut=”document.myImage.src=defaultImage.src;”>
- 9
- ”name=”myImage”width=100height=100border=0>
隨機(jī)顯示圖像
- 1
- 2varimageList=newArray;3:imageList[0]=“image1.jpg”;
- 3imageList[1]=“image2.jpg”;
- 4imageList[2]=“image3.jpg”;
- 5imageList[3]=“image4.jpg”;
- 6varimageChoice=Math.floor(Math.random()*imageList.length);
- 7document.write(‘
’); - 8
函數(shù)實(shí)現(xiàn)的圖像替換
- 1
- 2varsource=0;
- 3varreplacement=1;
- 4functioncreateRollOver(originalImage,replacementImage){
- 5varimageArray=newArray;
- 6imageArray[source]=newImage;
- 7imageArray[source].src=originalImage;
- 8imageArray[replacement]=newImage;
- 9imageArray[replacement].src=replacementImage;
- 10returnimageArray;
- 11}
- 12varrollImage1=createRollOver(“image1.jpg”,”rollImage1.jpg”);
- 13
- 14
- onMouseOver=”document.myImage1.src=rollImage1[replacement].src;”
- 15onMouseOut=”document.myImage1.src=rollImage1[source].src;”>
- 16
- ”width=100name=”myImage1”border=0>
- 17
創(chuàng)建幻燈片
- 1
- 2varimageList=newArray;
- 3imageList[0]=newImage;
- 4imageList[0].src=“image1.jpg”;
- 5imageList[1]=newImage;
- 6imageList[1].src=“image2.jpg”;
- 7imageList[2]=newImage;
- 8imageList[2].src=“image3.jpg”;
- 9imageList[3]=newImage;
- 10imageList[3].src=“image4.jpg”;
- 11functionslideShow(imageNumber){
- 12document.slideShow.src=imageList[imageNumber].src;
- 13imageNumber+=1;
- 14if(imageNumber
- 15window.setTimeout(“slideShow(“+imageNumber+“)”,3000);
- 16}
- 17}
- 18
- 19
- 20
- 21
隨機(jī)廣告圖片
- 1
- 2varimageList=newArray;
- 3imageList[0]=“image1.jpg”;
- 4imageList[1]=“image2.jpg”;
- 5imageList[2]=“image3.jpg”;
- 6imageList[3]=“image4.jpg”;
- 7varurlList=newArray;
- 8urlList[0]=“http://some.host/”;
- 9urlList[1]=“http://another.host/”;
- 10urlList[2]=“http://somewhere.else/”;
- 11urlList[3]=“http://right.here/”;
- 12varimageChoice=Math.floor(Math.random()*imageList.length);
- 13document.write(‘
’); - 14
文章題目:JavaScript中圖像處理技巧
本文URL:http://m.fisionsoft.com.cn/article/dhehpej.html


咨詢
建站咨詢
