📄 16.13.htm
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>访问图像属性</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<script type="text/javascript">
<!--
function showProps(theImage)
{ //定义一个str字符串,并为其赋值
var str="Image Properties\n\n";
//在字符串内添加图像的alt属性信息
str += "alt: "+theImage.alt + "\n";
//在字符串内添加图像的边框信息
str += "border: "+theImage.border + "\n";
//在字符串内添加图像是否载入的信息
str += "complete: "+theImage.complete + "\n";
//在字符串内添加图像的高度信息
str += "height: "+theImage.height + "\n";
//在字符串内添加图像的hspace属性信息
str += "hspace: "+theImage.hspace + "\n";
//在字符串内添加图像的lowsrc属性信息
// 这里使用lowsrc而不是lowSrc,因为IE6不支持后者
str += "lowsrc: "+theImage.lowsrc + "\n";
//在字符串内添加图像的名称信息
str += "name: "+theImage.name + "\n";
//在字符串内添加图像的src属性信息
str += "src: "+theImage.src + "\n";
//在字符串内添加图像的vspace属性信息
str += "vspace: "+theImage.vspace + "\n";
//在字符串内添加图像的宽度信息
str += "width: "+theImage.width + "\n";
alert(str); //弹出一个对话框,显示图像的相关属性信息
}
//-->
</script>
</head>
<body>
<center>
<h1>访问图像属性</h1><p>
<!--定义一个<img>,并设置其相关属性-->
<img src="image1.gif" alt="The Image" lowsrc="lowres.gif" id="testimage"
name="testimage" width="200" height="150" border="1"
hspace="10" vspace="15">
<br><br>
<form action="#" method="get">
<!--通过onclick调用showProps函数,显示图像的名称-->
<input type="button" value="显示属性"
onclick="showProps(document.images['testimage']);">
<!--通过onclick使用新图像替换原来的图像-->
<input type="button" value="替换图像"
onclick="document.testimage.src='image2.gif';"><p>
<!--通过onclick重新载入原来的图像-->
<input type="button" value="重新载入原图像"
onclick="document.testimage.src='image1.gif';">
</form>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -