javascript图像映射

黄雪林 2011-07-19 11:50:30
问题描述:我是想当鼠标滑过图像上的苹果时,在页面上的id=“txt”<P>标签上显示“这是苹果”,可是结果却是当鼠标滑过图像上得苹果后,整幅图像却消失了,“我是苹果”这些字没有显示在id=“txt”的<P>标签上。同样,梨子和葡萄也是一样的问题。html代码如下:
<!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>
<script type="text/javascript">
function write(txt)
{
document.getElementById('xie').innerHTML=txt;


}


</script>
<style type="text/css">
.dd{
height:40px;
width:200px;
background-color:yellow;
}

</style>
</head>
<body>
<img src="tu/shuiguo.jpg" usemap="#id" height="400px" width="400px" border="0" />
<map id="id" name="id">
<area coords="13,235,80,320" shape="rect" onmousemove="write('这是橙子')" />

<area shape="rect" coords="300,145,375,230" onmousemove="write('这是苹果')" />
<area shape="rect" coords="200,150,260,260" onmousemove="write('这是葡萄')" />

</map>
<br />:
<br />

<div id="xie" class="dd"></div>
</body>
</html>
希望有人能解决问题!
...全文
181 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
kyzy_yy_pm 2011-07-19
  • 打赏
  • 举报
回复
也就是换个函数名,js内置的有个document.write这个你应该知道,去掉document用write依然是等价于document.write
kyzy_yy_pm 2011-07-19
  • 打赏
  • 举报
回复
和js内置的write重名了,你应该叫_write就行了
黄雪林 2011-07-19
  • 打赏
  • 举报
回复

刚才问题描述那说错了,应该是id=“xie”的《div》标签上显示文字

87,989

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧