跟隨鼠標移動的文字

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<title>跟隨鼠標移動的文字</title>
<style>
.move_out{position:relative;cursor:hand;font-family:"華文行楷"}
</style>
</head>
<script language="javascript">
var move_out=false;//定義變量
var z,x,y;//定義變量
function move(){
	if(event.botton==move.out){//判斷當前鼠標是否是左鍵按下狀態
		z.style.pixelLeft=temporarily1+event.clientX-x;//獲取當前鼠標位置
		z.style.pixelTop=temporarily2+event.clientY-y;//獲取當前鼠標的位置
		return false;
	}
}
function down(){//創建自定義函數,實現文字的移動
	if(event.srcElement.className=="move_out"){//應用srcElement屬性獲取當前事件的對象
		move_out=true;
		z=event.srcElement;
		temporarily1=z.style.pixelLeft;
		temporarily2=z.style.pixelTop;
		x=event.clientX;//獲取鼠標在窗口中的X位置
		y=event.clientY;
		document.οnmοusemοve=move;
	}else{
		move_out=false;
	}
}
document.οnmοusedοwn=down;//當鼠標被按下時執行down函數
</script>
<body>
<font color="0000ff" size="10" class="move_out">吉林省明日科技</font>
</body>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章