
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
#content {
width: 100%;
height: 500px;
font-size: 80px;
}
</style>
</head>
<body>
<div id="content">显示内容部分</div>
<script>
function addWaterMarker(str) {
var can = document.createElement('canvas');
var body = document.body;
body.appendChild(can);
can.width = 125;
can.height = 110;
can.style.display = 'none';
var cans = can.getContext('2d');
cans.rotate(-20 * Math.PI / 180);
cans.font = "18px Microsoft JhengHei";
cans.fillStyle = "#e5e5e5";
cans.textAlign = 'left';
cans.textBaseline = 'Middle';
cans.fillText(str, can.width / 6, can.height / 2);
document.getElementById('content').style.backgroundImage = "url(" + can.toDataURL("image/png") + ")";
}
addWaterMarker('水印内容');
</script>
</body>
</html>