DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> javascript實現的白板效果(可以直接在網頁上寫字)
javascript實現的白板效果(可以直接在網頁上寫字)
編輯:關於JavaScript     
復制代碼 代碼如下:
<script type="text/javascript">
var ball;
var mouseX = 100;
var mouseY = 100;
var angle = 0;
var radius = 0;

function draw(){
ball = document.createElement("span");
ball.style.position = "absolute";
ball.style.color = "#FF0000";
ball.style.zIndex = 999999999;
ball.innerHTML = "●";
document.body.appendChild(ball);

ball.style["left"] = mouseX+ "px";
ball.style["top"] = mouseY+ "px";
}
function MousePos(e)
{
e = e || window.event;
var x,y;
if(!document.all){
x = e.pageX;
y = e.pageY;
}
else{
x = event.clientX + document.documentElement.scrollLeft;
y = event.clientY + document.documentElement.scrollTop;
}
return {x:x,y:y};
}
function setXY(e)
{
e = e || window.event;
var pos = MousePos(e);
mouseX = pos.x;
mouseY = pos.y;
draw();
}
window.onload = function(){
document.documentElement.onmousemove = function(e){
e = e || window.event;
setXY(e);
};
}
</script>

效果演示代碼:

[Ctrl+A 全選 注:如需引入外部Js需刷新才能執行]
出處:http://www.cnblogs.com/airy
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved