`
bo_hai
  • 浏览: 564218 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

鼠标移到图片,查看源图的实现

 
阅读更多

页面如下:

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<base href="<%=basePath%>">	
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<script language="javascript"  src="<%=basePath%>JQuery/jquery-1.6.js"></script>
		<script language="javascript"  src="<%=basePath%>JQuery/jquery.validate.js"></script>
		<script language="javascript"  src="<%=basePath%>JQuery/jquery.form.js"></script>		
		<title>Welcome Here</title>
		<script type="text/javascript">
			$(function(){
				$("img[name='productImg']").mouseover(
				            function(){
				            	var top=$(this).offset().top;
				            	var left=$(this).offset().left;
				            	$("#imgPreview").attr("src",this.id).show().offset({top:top-100,left:left+50});
				            	
				            }
			            ).mouseout(
			           		 function(){
			            		$("#imgPreview").hide().removeAttr("src");
			            });
			});			
		</script>
	</head>
	<body>
		<img name="productImg" src="<%=basePath %>/image/3701873.jpg" id="<%=basePath %>/image/3701873.jpg" width="45px" height="45px">
		<img id='imgPreview' style="border-width:2;border-color:#000000;display:none;position:absolute"/>
	</body>
</html>

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics