代码如下:
<html><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><br />
<title>模拟Windows升级页面特效</title><br />
</head><br />
<body><br />
<script language=<a href="http://www.chinaitpower.com/Dev/Programme/Java/index.html" target="_blank">java</a>script><br />
var BorderMove = new Object();<br />
BorderMove.getx = function(tag)<br />
{<br />
x = tag.offsetLeft;<br />
while(tag = tag.offsetParent)<br />
{<br />
x += tag.offsetLeft;<br />
}<br />
return x;<br />
}<br />
BorderMove.gety = function(tag)<br />
{<br />
y = tag.offsetTop;<br />
while(tag = tag.offsetParent)<br />
{<br />
y += tag.offsetTop;<br />
}<br />
return y;<br />
}<br />
BorderMove.Init = function()<br />
{<br />
this.BeginWidth = window.document.body.offsetWidth;<br />
this.BeginHeight = window.document.body.offsetHeight;<br />
this.BeginLeft = window.document.body.offsetLeft;<br />
this.BeginTop = window.document.body.offsetTop;<br />
this.EndLeft = this.getx(this.toElementObj) + this.toElementObj.offsetWidth / 2;<br />
this.EndTop = this.gety(this.toElementObj) + this.toElementObj.offsetHeight / 2;<br />
this.TimeOut = 20;<br />
this.MoveTime = 16;<br />
this.Moved = 0<br />
this.Distance = Math.sqrt(this.BeginLeft * this.BeginLeft + this.EndLeft * this.EndLeft);<br />
this.MoveLeft = (this.EndLeft - this.BeginLeft) / this.MoveTime;<br />
this.MoveTop = (this.EndTop - this.BeginTop) / this.MoveTime;<br />
this.ContractWidth = this.BeginWidth / this.MoveTime;<br />
this.ContractHeight = this.BeginHeight / this.MoveTime;<br />
this.TimeOutId = null;<br />
this.Div = window.document.createElement("DIV");<br />
window.document.body.appendChild(this.Div);<br />
}<br />
BorderMove.Display = function(srcElementObjId,toElementObjId)<br />
{<br />
if(this.TimeOutId != null)<br />
{<br />
window.clearTimeout(this.TimeOutId);<br />
window.document.body.removeChild(this.Div);<br />
this.Div = null;<br />
} <br />
this.srcElementObj = window.document.getElementById(srcElementObjId);<br />
this.toElementObj = window.document.getElementById(toElementObjId);<br />
this.Init(); <br />
with(this.Div.style)<br />
{<br />
width = this.BeginWidth;<br />
height = this.BeginHeight;<br />
border = "1 dotted #cccccc";<br />
position = "absolute";<br />
left = this.BeginLeft;<br />
top = this.BeginTop;<br />
}<br />
<br />
this.Move();<br />
}<br />
BorderMove.Move = function()<br />
{<br />
this.BeginWidth -= this.ContractWidth;<br />
this.BeginHeight -= this.ContractHeight;<br />
this.BeginLeft += this.MoveLeft;<br />
this.BeginTop += this.MoveTop;<br />
with(this.Div.style)<br />
{<br />
width = this.BeginWidth;<br />
height = this.BeginHeight;<br />
left = this.BeginLeft;<br />
top = this.BeginTop;<br />
}<br />
this.Moved++;<br />
if(this.Moved == this.MoveTime)<br />
{<br />
window.document.body.removeChild(this.Div);<br />
this.Div = null;<br />
this.Init();<br />
}<br />
else<br />
{<br />
this.TimeOutId = setTimeout("BorderMove.Move()",this.TimeOut);<br />
}<br />
}<br />
</script><br />
<br><br><br><br><br><br><br><br><br />
<center><span id=Text>虚影目标对象</span></center><br />
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br />
<br />
<input type=button value="事件触发对象" onclick="BorderMove.Display(this.id,'Text')" id="Button"><br />
</body><br />
</html>
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]