Google eye HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>GoogleEye.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	<script type="text/javascript">
	var eye1;
	var eye2;
	function load()
	{
		eye1 = new Eye();
		eye1.init();
		eye2 = new Eye();
		eye2.init();
		eye2.circle.style.border = "1px solid yellow";
		eye2.moveTo(320, 200);
	}

	function Eye()
	{

		this.distance = 53;
		this.middlex = 200;
		this.middley = 200;

		// 眼圈
		this.circle = document.createElement('div');
		document.getElementById('eye').appendChild(this.circle);
		this.circle.style.border = "1px solid red";
		this.circle.style.position = "absolute";
		this.circle.style.display = "block";
		this.circle.style.width = this.distance * 2;
		this.circle.style.height = this.distance * 2;
		this.circle.style.top = this.middley - this.distance;
		this.circle.style.left = this.middlex - this.distance;

		// 眼球
		this.ball = document.createElement('div');
		this.circle.appendChild(this.ball);
		this.ball.style.backgroundColor = "black";
		this.ball.style.position = "absolute";
		this.ball.style.display = "block";
		this.ball.style.width = "6px";
		this.ball.style.height = "6px";
		this.ball.style.top = this.distance;
		this.ball.style.left = this.distance;

		this.init = function()
		{
			if (window.attachEvent)
			{
				window.attachEvent("onmousemove", this.move);
			} else
			{
				window.addEventListener("mousemove", this.move, false);
			}
		}

		var own = this;
		this.setSize = function(distan)
		{
			this.distance = distan;
			this.circle.style.width = this.distance * 2;
			this.circle.style.height = this.distance * 2;
			this.circle.style.top = this.middley - this.distance;
			this.circle.style.left = this.middlex - this.distance;
			this.ball.style.top = this.distance;
			this.ball.style.left = this.distance;
		}
		this.moveTo = function(x, y)
		{
			this.middlex = x;
			this.middley = y;
			this.circle.style.top = this.middley - this.distance;
			this.circle.style.left = this.middlex - this.distance;
		}

		this.move = function(event)
		{
			var even;
			if (window.event)
			{
				even = window.event;
			} else
			{
				even = event;
			}
			var xpos = even.clientX;
			var ypos = even.clientY;
			xpos -= own.middlex;
			ypos -= own.middley;
			var dist = Math.sqrt(xpos * xpos + ypos * ypos);

			if (dist < own.distance)
			{
				own.ball.style.top = ypos + own.distance;
				own.ball.style.left = xpos + own.distance;
			} else
			{
				var k, y, x;
				if (ypos != 0)
				{
					k = xpos / ypos;
					y = own.distance / Math.sqrt(k * k + 1);
					if (ypos < 0)
						y = -y;
					x = k * y;
				} else
				{
					y = 0;
					x = own.distance;
					if (xpos < 0)
						x = -x;
				}

				own.ball.style.left = x + own.distance;
				own.ball.style.top = y + own.distance;
			}

		}
	}
	function go()
	{
		load();
	}
	</script>
  </head>
  
  <body οnlοad="go()">
	<div id='eye'>
	</div>
  </body>
</html>

Google eye 页面...大部分都是参考的..

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值