Home
visit our sponsor
Dynamic Html Main Page

Scroll Up and Down

 


นำ Code ไปวางไว้ในส่วนของ <Head >

<STYLE type=text/css>#divUpControl {
Z-INDEX: 1; LEFT: 10px; WIDTH: 320px; POSITION: absolute; TOP: 10px; TEXT-ALIGN: right
}
#divDownControl {
Z-INDEX: 1; LEFT: 10px; WIDTH: 320px; POSITION: absolute; TOP: 270px; TEXT-ALIGN: right
}
#divContainer {
LEFT: 10px; VISIBILITY: hidden; OVERFLOW: hidden; WIDTH: 320px; CLIP: rect(0px 320px 240px 0px); POSITION: absolute; TOP: 30px; HEIGHT: 240px
}
#divContent {
LEFT: 0px; POSITION: absolute; TOP: 0px
}
</STYLE>

<SCRIPT language=JavaScript>
function verifyCompatibleBrowser(){
this.ver=navigator.appVersion
this.dom=document.getElementById?1:0
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;

this.ns4=(document.layers && !this.dom)?1:0;
this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
return this
}
bw=new verifyCompatibleBrowser()

var speed=50
// ปรับค่าความเร็วในการเลื่อนตัวอักษร

var loop, timer

function ConstructObject(obj,nest){
nest=(!nest) ? '':'document.'+nest+'.'
this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
this.up=MoveAreaUp;this.down=MoveAreaDown;
this.MoveArea=MoveArea; this.x; this.y;
this.obj = obj + "Object"
eval(this.obj + "=this")
return this
}
function MoveArea(x,y){
this.x=x;this.y=y
this.css.left=this.x
this.css.top=this.y
}

function MoveAreaDown(move){
if(this.y>-this.scrollHeight+objContainer.clipHeight){
this.MoveArea(0,this.y-move)
if(loop) setTimeout(this.obj+".down("+move+")",speed)
}
}
function MoveAreaUp(move){
if(this.y<0){
this.MoveArea(0,this.y-move)
if(loop) setTimeout(this.obj+".up("+move+")",speed)
}
}

function PerformScroll(speed){
if(initialised){
loop=true;
if(speed>0) objScroller.down(speed)
else objScroller.up(speed)
}
}

function CeaseScroll(){
loop=false
if(timer) clearTimeout(timer)
}
var initialised;
function InitialiseScrollableArea(){
objContainer=new ConstructObject('divContainer')
objScroller=new ConstructObject('divContent','divContainer')
objScroller.MoveArea(0,0)
objContainer.css.visibility='visible'
initialised=true;
}

</SCRIPT>

นำ Code นี้ไปวางในส่วนของ <Body >

<BODY bgColor=#ffffff onload=InitialiseScrollableArea()>
<DIV id=divUpControl><A
onclick=PerformScroll(-3) onmouseout=CeaseScroll()
//ค่าที่เป็นตัวเลขคือจำนวนบรรทัดที่ต้องการให้เลื่อน
href="javascript:;">
เลื่อนลง</A> </DIV>
<DIV id=divDownControl><A onclick=PerformScroll(3) onmouseout=CeaseScroll()

//ค่าที่เป็นตัวเลขคือจำนวนบรรทัดที่ต้องการให้เลื่อน

href="javascript:;">
เลื่อนขึ้น</A> </DIV>
// สามารถเปลี่ยน Onclick เป็น Onmouseover ได้ถ้าต้องการให้เลื่อนข้อความเมื่อเลื่อนเม้าส์ไปทับคำว่าเลื่อนขึ้นหรือเลื่อนลง

<DIV id=divContainer>
<DIV id=divContent>
พิมพ์ข้อความที่คุณต้องการต่อจาก Tag นี้เป็นต้นไป</Div></Div>

อย่าลืมใส่ Tag </Div> 2 ครั้งปิดท้ายข้อความที่คุณพิมพ์เสร็จแล้วด้วย Top of PageBack to Previous Page

 
visit our sponsor
Free web template Learning Photoshop 6.0 Technic

Download Software Graphic webboard

Graphic and webdesign Links Website design service Contact Us