[html]
<html>
<head>
<title>添加图片</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<table width="100%" border="1" cellpadding="5" cellspacing="0" bordercolor="#999999" bgcolor="#ffffff">
<tr>
<td ><form >
<input name="tpi" type="file" size="50" onchange=Pc3(this)>
<input name="i" type="hidden">
</form></td>
</tr>
</table>
<script>
function Pc3(n)
{
a=n.value
Pv.innerHTML="<img src='"+a+"'>";
}
</script>
<div id=Pv></div>
</body>
</html>
[/html]
该博客展示了用HTML实现添加图片的代码。通过创建表格,在表格内的表单中设置文件输入框,当选择文件时触发函数,将所选图片显示在指定的div中,涉及HTML标签和简单的JavaScript函数。
1万+

被折叠的 条评论
为什么被折叠?



