取代.参考这个标题
Replace this.href with this.title
当用户将鼠标放在图像映射的热点上时,下面的代码可以完美地显示图像。唯一的问题是什么?当点击"this。Href '当然会将用户带到热点图像本身。我想保留'href'来将用户发送到我选择的页面。
是否可以使用"title"而不是"href"来定义热点图像?如果有,请详细说明,我对javascript很陌生,谢谢!
<script type="text/javascript">
function ShowPicC(sImage){document.housec.src = sImage}
</script>
<img border="0" src="main-image.png" width="640" height='640' usemap="#FPMap0">
<map name="FPMap0">
<area onmouseover='ShowPicC(this.href)' href='hotspot1.png' alt="thisalt" title="can-png-go-here.png" shape="circle" coords="400,400,20">
<area onmouseover="ShowPicC(this.href)" href="hotspot2.jpg" alt="youralt" title="can-png-go-here2.png" shape="circle" coords="420,420,20">
<area onmouseover="ShowPicC(this.href)" href="hotspot3.jpg" alt="differentalt" title="can-png-go-here3.png" shape="circle" coords="440,440,20">
<area onmouseover="ShowPicC(this.href)" href="hotspot4.jpg" alt="whateveralt" title="can-png-go-here4.png" shape="circle" coords="460,460,20">
</map>
<img name="housec" src="starter-hotspot-image.png" width="192" height="170">
当然可以,尽管title
不是area
的有效属性。你试过吗?
<area onmouseover="ShowPicC(this.title)" title="someotherimage.jpg" ...
你最好使用数据属性:
<area data-image="someotherimage.jpg" ...
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes 相关文章:
- CSS-如何定位内容数据标题
- 在PHP中使用javascript更改页面标题'if'
- 相位器状态未捕获参考错误
- Brightcove获取/显示HTML中的当前视频标题和描述
- React组件-设置页面标题
- jQuery动态更改标题
- HighCharts长标题文本在某些元素上重叠
- 将行添加到具有固定标题的HTML表中
- 聚合物0.5.5:核心列表中的条件模板和/或模板动态参考
- CKEditor v4:自制插件中对话框的动态标题
- Javascript袖珍参考,第121页:这是怎么回事;猴子补丁”;方法应该有效
- 如何在自动完成时设置属性标题
- 单元格的工具提示或标题不显示超过2000个字符
- 如何从相应的控制器动态更新标题和描述
- 将超链接添加到“;标题“;标记文本
- 为什么我会出现此错误"未捕获引用错误:未定义标题;
- FullCalendar:事件发生时阻止重叠.标题是一样的
- 任何Java对脚本语言语法的支持,类似于Foobar2000:标题格式参考
- 取代.参考这个标题
- 参考资料 修改立体主义.js石墨标题文字,看不到屏幕上的数据