類比Windows升級頁面特效

來源:互聯網
上載者:User

代碼如下:


<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=javascript><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 /> }</p><p> 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></p><p><input type=button value="事件觸發對象" onclick="BorderMove.Display(this.id,'Text')" id="Button"><br /></body><br /></html>
[Ctrl+A 全選 提示:你可先修改部分代碼,再點運行代碼]

轉自: http://goaler.xicp.net/Article/ShowArticle.asp?ID=471

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.