미리보기 : |
---|
따라다니는 레이어 입니다. Top 버튼으로도 사용가능하며 가로를 넓게 할시 다른용도로도 사용할수 있습니다.
미리보기 : http://www.hankyung.com/news/app/newsview.php?aid=2008011348331
<head>와 </head>사이에 아래소스삽입
<script type="text/javascript">
function Floating ( FloatingObj , MarginY , TopLimit , Percentage , setTime ) {
this.FloatingObj = FloatingObj;
this.MarginY = (MarginY) ? MarginY : 400; // top 위치
this.TopLimit = (TopLimit) ? TopLimit : 0;
this.Percentage = (Percentage) ? Percentage : 20;
this.setTime = (setTime) ? setTime : 10;
this.FloatingObj.style.position = "absolute";
this.Body = null;
this.setTimeOut = null;
this.Run();
}
Floating.prototype.Run = function () {
this.Body = document.documentElement.scrollTop>document.body.scrollTop ? document.documentElement : document.body;
var This = this;
var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top,10) : this.FloatingObj.offsetTop;
var DocTop = this.Body.scrollTop + this.MarginY;
var MoveY = Math.abs(FloatingObjTop - DocTop);
if ( DocTop > this.TopLimit ) {
if ( FloatingObjTop < DocTop ) {
this.FloatingObj.style.top = FloatingObjTop + Math.ceil( MoveY/this.Percentage ) + "px" ;
} else {
this.FloatingObj.style.top = DocTop + "px" ;
}
} else {
this.FloatingObj.style.top = this.TopLimit + "px" ;
}
window.clearTimeout(this.setTimeOut);
this.setTimeOut = window.setTimeout( function () { This.Run(); } , this.setTime );
}
</script>
<body>와 </body> 사이 원하는 위치에 아래소스 삽입
<div id="cTop" style="position:absolute; left:823px; z-index:1;">
<a href="./#"><img src="./이미지경로" alt="위로가기" /></a>
</div>
<script type="text/javascript">
new Floating(document.getElementById('cTop'),0,700,10,10);
</script>
</div>
응용해 보세요.
추천수 10단위당 메달이 1개씩 노출되고, 추천수에 따라 배경색이 변하며, 일정수의 추천수를 받을시 아이콘이 붙게됩니다.
- 추천수 50개이상
- 추천수 30개이상
- 추천수 20개이상
- 추천수 10개이상
- 추천수 3개이상