当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 一个跟随鼠标的图片放大效果,与FF兼容

Javascript
AJAX教程(14):通过XMLHTTP加载XML文件
AJAX教程(15):通过XMLHTTP进行一次HEAD请求
AJAX教程(16):通过XMLHTTP进行一次指定的HEAD请求
AJAX教程(17):把XML文件显示为HTML表格
JS通过WMI获取客户端硬件信息
JavaScript中使用远程脚本
关于Ajax技术的注意事项
XMLHttpRequest创建智能表单
iframe创建智能表单
JS教程:线小测试程序
在Web页面中使用计时器
将事件处理器作为HTML标记的属性
事件处理器作为浏览器对象的属性
Math对象应用详解
random()方法和pow()方法
charAt()方法和charCodeAt()方法
Number对象常用的toFixed()方法
JS教程:为什么尽量用局部变量代替全局变量
解决JavaScript循环中的过多操作
处理提示“脚本运行时间过长的提示框”问题

Javascript 中的 一个跟随鼠标的图片放大效果,与FF兼容


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 164 ::
收藏到网摘: n/a

<div align=center style="overfow: hidden; width: 100px; height: 100px"><img src="/upload/tech/20091012/20091012084928_4ea06fbc83cdd0a06020c35d50e1e89a.jpg" width="100" height="100" border="0" onmouseover="show(this)" onmouseout="hide(this)">
</div>
<div align=center style="overfow: hidden; width: 100px; height: 100px">
<img src="/upload/tech/20091012/20091012084928_37693cfc748049e45d87b8c7d8b9aacd.jpg" width="100" height="100" border="0" onmouseover="show(this)" onmouseout="hide(this)">
</div>
<div align=center style="overfow: hidden; width: 100px; height: 100px">
<img src="/upload/tech/20091012/20091012084934_437d7d1d97917cd627a34a6a0fb41136.jpg" width="100" height="100" border="0" onmouseover="show(this)" onmouseout="hide(this)">
</div>
<div id="enlarge_images" style="position: absolute; z-index:2"></div>
<SCRIPT>
function show(_this) {
document.getElementById("enlarge_images").innerHTML = "<img src='" + _this.src + "' >";
}
function hide(_this) {
document.getElementById("enlarge_images").innerHTML = "";
}
function move_layer(event){
event = event || window.event;
enlarge_images.style.left=event.clientX+document.body.scrollLeft+10;
enlarge_images.style.top=event.clientY+document.body.scrollTop+10;
}
document.onmousemove =move_layer;
</SCRIPT>

点击运行可以看到效果:
[Ctrl+A 全选 提示:你可先修改部分代码,再按运行]