|
发表于 2016-12-11 10:06:36
高大上手机用户
|
显示全部楼层
|阅读模式
江苏省徐州市
function getCanvasFingerprint() {
var canvas = document.createElement("canvas");
canvas.width = 2000;
canvas.height = 200;
canvas.style.display = "inline";
var ctx = canvas.getContext("2d");
ctx.rect(0, 0, 10, 10);
ctx.rect(2, 2, 6, 6);
var winding = (ctx.isPointInPath(5, 5, "evenodd") === false) ? "yes": "no";
ctx.textBaseline = "alphabetic";
ctx.fillStyle = "#f60";
ctx.fillRect(125, 1, 62, 20);
ctx.fillStyle = "#069";
ctx.font = "11pt no-real-font-123";
ctx.fillText("code is developer by huoniu, \ud83d\ude03", 2, 15);
ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
ctx.font = "18pt Arial";
ctx.fillText("code is developer by huoniu, \ud83d\ude03", 4, 45);
ctx.globalCompositeOperation = "multiply";
ctx.fillStyle = "rgb(255,0,255)";
ctx.beginPath();
ctx.arc(50, 50, 50, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
ctx.fillStyle = "rgb(0,255,255)";
ctx.beginPath();
ctx.arc(100, 50, 50, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
ctx.fillStyle = "rgb(255,255,0)";
ctx.beginPath();
ctx.arc(75, 100, 50, 0, Math.PI * 2, true);
ctx.closePath();
ctx.fill();
ctx.fillStyle = "rgb(255,0,255)";
ctx.arc(75, 75, 75, 0, Math.PI * 2, true);
ctx.arc(75, 75, 25, 0, Math.PI * 2, true);
ctx.fill("evenodd");
var fp = canvas.toDataURL();
return winding + "~" + fp
}
这个在JS调试工具里能加载成功。但是调试的时候就显示'document' 未定义,这个应该怎么弄??
|
|