JavaScript Lite Learning 3: Images

Source: Internet
Author: User
JavaScript 36 Read Image properties
1:
2: <a href= "#" onclick= "Window.alert (document.myImage.width)" >Width</a>
3:

37 Dynamically loading images
1: <script language= "JavaScript" >
2:myimage = new Image;
3:MYIMAGE.SRC = "Tellers1.jpg";
4: </script>

38 Simple Image Replacement
1: <script language= "JavaScript" >
2:rollimage = new Image;
3:ROLLIMAGE.SRC = "Rollimage1.jpg";
4:defaultimage = new Image;
5:DEFAULTIMAGE.SRC = http://www.webjx.com/htmldata/2006-02-06/"Image1.jpg";
6: </script>
7: <a href= "Myurl" onmouseover= "document.myImage.src = rollimage.src;"
8:onmouseout= "document.myImage.src = defaultimage.src;" >
9:

39 Random Display Image
1: <script language= "JavaScript" >
2:var imageList = new Array;
3:imagelist[0] = http://www.webjx.com/htmldata/2006-02-06/"image1.jpg";
4:IMAGELIST[1] = "image2.jpg";
5:IMAGELIST[2] = "image3.jpg";
6:IMAGELIST[3] = "image4.jpg";
7:var Imagechoice = Math.floor (Math.random () * imagelist.length);
8:document.write (' ');
9: </script>

40 function implementation of image replacement
1: <script language= "JavaScript" >
2:var Source = 0;
3:var replacement = 1;
4:function Createrollover (originalimage,replacementimage) {
5:var Imagearray = new Array;
6:imagearray[source] = new Image;
7:IMAGEARRAY[SOURCE].SRC = Originalimage;
8:imagearray[replacement] = new Image;
9:IMAGEARRAY[REPLACEMENT].SRC = Replacementimage;
10:return Imagearray;
11:}
12:var rollImage1 = Createrollover (http://www.webjx.com/htmldata/2006-02-06/"image1.jpg", "rollimage1.jpg");
</script>
<a href= "#" onmouseover= "document.myImage1.src = rollimage1[replacement].src;"
15:onmouseout= "document.myImage1.src = rollimage1[source].src;" >
:
: </a>

41 Creating slides
1: <script language= "JavaScript" >
2:var imageList = new Array;
3:imagelist[0] = new Image;
4:IMAGELIST[0].SRC = http://www.webjx.com/htmldata/2006-02-06/"Image1.jpg";
5:IMAGELIST[1] = new Image;
6:IMAGELIST[1].SRC = "Image2.jpg";
7:IMAGELIST[2] = new Image;
8:IMAGELIST[2].SRC = "Image3.jpg";
9:IMAGELIST[3] = new Image;
10:IMAGELIST[3].SRC = "Image4.jpg";
11:function Slideshow (imagenumber) {
12:DOCUMENT.SLIDESHOW.SRC = IMAGELIST[IMAGENUMBER].SRC;
13:imagenumber + 1;
14:if (Imagenumber < imagelist.length) {
15:window.settimeout ("slideshow (" + Imagenumber + ")", 3000);
16:}
17:}
: </script>
: £ <body onload= "slideshow (0)" >
:

42 Random Advertising Pictures
1: <script language= "JavaScript" >
2:var imageList = new Array;
3:imagelist[0] = http://www.webjx.com/htmldata/2006-02-06/"image1.jpg";
4:IMAGELIST[1] = "image2.jpg";
5:IMAGELIST[2] = "image3.jpg";
6:IMAGELIST[3] = "image4.jpg";
7:var urllist = new Array;
8:urllist[0] = " http://some.host/”;
9:URLLIST[1] = " http://another.host/”;
10:URLLIST[2] = " http://somewhere.else/”;
11:URLLIST[3] = " http://right.here/”;
12:var Imagechoice = Math.floor (Math.random () * imagelist.length);
13:document.write (' <a href= "' + Urllist[imagechoice] + '" >: </script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.