6.javascript---第三天源代码

ImageTest1.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<!--鼠标动作时图片会产生动作-->
<HTML>

<HEAD>

<TITLE> ImageTest1 </TITLE>
</HEAD>

<BODY>
<script language="javascript">
var defaultImage = new Image;
defaultImage.src = "winxpaa11.jpg";
var rolledImage = new Image;
rolledImage.src = "winxpaa13.jpg";
var thirdImage = new Image;
thirdImage.src = "winxpaa10.jpg";
/*<img src = "C:/Documents and Settings/Administrator/My
Documents/壁纸/winxpaa14.jpg" name = "myImage">
<a href = "#" onClick = "window.alert(document.myImage.width)">width</a><br>
<a href = "#" onClick = "window.alert(document.myImage.height)"><img src =
"C:/Documents and Settings/Administrator/My Documents/壁纸/winxpaa13.jpg" name =
"myImage2"></a><br><br><br>
*/
</script>
<img src="winxpaa14.jpg" name="myImage" onClick="window.alert('fefef');">
<a href="#" onClick="document.myImage3.src = defaultImage.src;"
onMouseOver="document.myImage3.src = rolledImage.src" onMouseOut="document.myImage3.src =defaultImage.src">
<image src="winxpaa15.jpg" name="myImage3">
</a><br>

</BODY>

</HTML>

ImageTest2.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--用于显示3个随机图片-->

<HTML>

<HEAD>
<TITLE> ImageTest2 </TITLE>
<script language="javascript">
var imageList = new Array;
for (var i = 0; i < 5; i++) {
imageList[i] = "winxpaa1" + i + ".jpg";
}

function X() { //var s = "<img src = C:/Documents and Settings/Administrator/My
Documents / 壁纸 / winxpaa13.jpg > ";
//document.write(s);
var imageChoice = Math.floor(Math.random() * imageList.length);
document.write('<img src="' + imageList[imageChoice] + '"width = 100 height =
100 > ');
}
</script>
</HEAD>

<BODY>
<script language="javascript">
X();
X();
X();
</script>

</BODY>

</HTML>