<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="img/jquery-1.10.1.js" type="text/javascript"></script>
<style type="text/css">
* { margin:0; padding:0; text-align:center;}
body {TEXT-ALIGN: center;}
#center { MARGIN-RIGHT: auto; MARGIN-LEFT: auto; }
</style>
<script type="text/javascript">
$(document).ready(function () {
var canvers = document.getElementById("diagonal");
var context = canvers.getContext("2d");
context.globalAlpha = 0.5;
$("#Map area").each(function () {
//$(this).mouseover(function () {
context.beginPath();
//定义一数组
var strs = $(this).attr("coords").split(",");
var i1, i2;
for (var i = 0; i < strs.length; i++) {
if (i % 2 === 0) {
i1 = strs[i];
}
if (i % 2 === 1) {
i2 = strs[i];
if (i === 1) {
context.moveTo(i1, i2);
}
else {
context.lineTo(i1, i2);
}
}
}
context.fillStyle = "#333333";
context.fill();
context.closePath(); //闭合
//});
//$(this).mouseout(function () {
// context.clearRect(0, 0, 750, 528);
//});
});
});
</script>
</head>
<body>
<div id="center" style="width:750px;">
<div style="display: block; background: url('img/1.jpg') repeat scroll 0% 0% transparent; padding: 0px; width: 750px; height: 528px; position: relative;">
<canvas id="diagonal" style="border:0px none;top:0px;left:0;position:absolute; padding: 0px; opacity: 1;" width="750px" height="528px"></canvas>
<img src="img/1.jpg" width="750px" usemap="#Map" style="border: 0px none;position:absolute;left:0;top:0;opacity:0;"/>
<map id="Map" name="map">
<area shape="poly" coords="287,45, 34,344, 200,450, 323,440"
style="display:block;background-color:#000000;" href="position.html" />
</map>
</div>
</div>
</body>
</html>