87,907
社区成员
发帖
与我相关
我的任务
分享
<div class="left">
<div id="back_human" class="left1">
<img src="/img/human1.gif" width="200" height="200" id="bui1" name="bui1" runat=server galleryimg="no" />
<img src="/img/maru.gif" width="16" height="18" alt="受傷部位" id="maru1" class="maru" /></div>.......
</div>>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.left1{
position:relative;
}
.maru{
display:none; position:absolute;
}
</style>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
function getOffset (obj){
var x = 0, y = 0;
do{
x += obj.offsetLeft;
y += obj.offsetTop;
obj = obj.offsetParent;
}while(obj);
return {x:x, y:y};
};
window.onload = function(){
$("bui1").onclick = function(oEvent){
oEvent = oEvent || window.event;
$("maru1").style.display = "block";
var parentOffset = getOffset($("back_human"));
var eventX, eventY;
if(document.all){
eventX = document.body.scrollLeft + oEvent.clientX;
eventY = document.body.scrollTop + oEvent.clientY;
}else{
eventX = oEvent.pageX;
eventY = oEvent.pageY;
}
$("maru1").style.left = eventX - parentOffset.x - 2 + "px";
$("maru1").style.top = eventY - parentOffset.y - 2 + "px";
};
};
</script>
</head>
<body>
<div class="left">
.......
<div id="back_human" class="left1">
<img src="http://www.google.cn/intl/zh-CN/images/logo_cn.gif" width="200" height="200" id="bui1" name="bui1" runat=server galleryimg="no" />
<img src="http://www.google.cn/intl/zh-CN/options/icons/finance.gif" width="16" height="18" alt="受傷部位" id="maru1" class="maru" />
</div>.......
</div>
</body>
</html>
function addKizu(i, e) {
var $no = $('#no' + i);
if ($no.val() > (5 * i)) {
return;
}
$('#maru' + $no.val()).css({
'left' : (e.pageX - 8) + 'px',
'top' : (e.pageY - 9) + 'px',
'display' : 'block'
});
$no.get(0).value++;
}
$(function() {
$('#no1').val(1);
$('#no2').val(6);
$('#bui1').click(function(e) {
addKizu(1, e);
});
$('#bui2').click(function(e) {
addKizu(2, e);
});
});
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.maru{
display:none; position:absolute;
}
</style>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
window.onload = function(){
$("bui1").onclick = function(oEvent){
oEvent = oEvent || window.event;
$("maru1").style.display = "block";
var eventX, eventY;
if(document.all){
eventX = document.body.scrollLeft + oEvent.clientX;
eventY = document.body.scrollTop + oEvent.clientY;
}else{
eventX = oEvent.pageX;
eventY = oEvent.pageY;
}
$("maru1").style.left = eventX - 2 + "px";
$("maru1").style.top = eventY - 2 + "px";
};
};
</script>
</head>
<body>
<div class="left">
<div id="back_human" class="left1">
<img src="http://www.google.cn/intl/zh-CN/images/logo_cn.gif" width="200" height="200" id="bui1" name="bui1" runat=server galleryimg="no" />
<img src="http://www.google.cn/intl/zh-CN/options/icons/finance.gif" width="16" height="18" alt="受傷部位" id="maru1" class="maru" />
</div>.......
</div>
</body>
</html>
<html>
<head>
<script language="javascript">
function init(){
document.getElementById("bui1").onclick=function(e){
e = e || window.event;
var smallpic = document.getElementById("maru1");
smallpic.style.top = (e.y || e.pageY);
smallpic.style.left = (e.x || e.pageX);
smallpic.style.display = "block";
}
}
</script>
</head>
<body onload="init()">
<img src="http://www.google.cn/intl/zh-CN/images/logo_cn.gif" width="200" height="200" id="bui1" name="bui1" galleryimg="no"/>
<img src="http://www.google.cn/intl/zh-CN/images/logo_cn.gif" style="position:absolute;display:none;" width="16" height="18" alt="受傷部位" id="maru1" class="maru" />
</body>
</html>