0
我想要自動滾動一個Div,而不是從頂部到底部或從底部到頂部,我需要它從左到右!自動滾動Div從左到右?
我發現了一個完全符合我需要的代碼,但它只是自下而上。
這是代碼:
<script type="text/javascript">
/***********************************************
* IFRAME Scroller script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//Specify speed of scroll. Larger=faster (ie: 5)
var scrollspeed=cache=2
//Specify intial delay before scroller starts scrolling (in miliseconds):
var initialdelay=500
function initializeScroller() {
dataobj = document.all? document.all.datacontainer :
document.getElementById("datacontainer")
dataobj.style.top = "5px"
setTimeout("getdataheight()", initialdelay)
}
function getdataheight() {
thelength=dataobj.offsetHeight
if (thelength == 0)
setTimeout("getdataheight()",10)
else
scrollDiv()
}
function scrollDiv() {
dataobj.style.top=parseInt(dataobj.style.top)-scrollspeed+"px"
if (parseInt(dataobj.style.top) < thelength*(-1))
dataobj.style.top = "5px"
setTimeout("scrollDiv()",40)
}
if (window.addEventListener)
window.addEventListener("load", initializeScroller, false)
else if (window.attachEvent)
window.attachEvent("onload", initializeScroller)
else
window.onload=initializeScroller
</script>
有誰知道如何使這個腳本移動事業部左右,而不是底部到頂部?順便說一句,我對JavaScript很新,所以請溫柔一點。
感謝
做到了。非常感謝。 – user2056633 2013-02-26 00:21:07
不客氣,祝你的項目好運。 – 2013-02-26 00:22:09