标志位置的时候,导入的那个图标不能显示出来,是一个损坏的图片的样子
<!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=utf-8" />
<title>无标题文档</title>
</head>
<body>
<style>
html,body{margin:0px;height:100%;}
#dv{width:100%;height:100%;margin:0px auto;}
.img .marker{position:absolute;}
</style>
<div class="img" id="dv">
<img src="F:\毕业设计\新建文件夹\map.png" alt="map""></div>
<script>
function createMarker(x, y) {
var div = document.createElement('img');
div.className = 'marker'; div.style.left = x + 'px'; div.style.top = y + 'px';
document.getElementById('dv').appendChild(div
)
}
document.getElementById('dv').onclick = function (e) {
e = e || window.event;
var x = e.offsetX || e.layerX, y = e.offsetY || e.layerY;
createMarker(x, y);
}
function createMarker(x, y) {
var img = document.getElementById('imgMarker');
if (!img) {//不存在创建
img = document.createElement('img'); img.id = 'imgMarker'; img.src = 'C:\Users\Administrator\Desktop\dibiao.jpg'; img.className = 'marker';
document.getElementById('dv').appendChild(img)
}
img.style.left = x + 'px'; img.style.top = y + 'px';
}
</script>