js新聞滾動(dòng) js如何實(shí)現(xiàn)新聞滾動(dòng)效果
更新時(shí)間:2013年01月07日 17:34:15 作者:
JS實(shí)現(xiàn)新聞滾動(dòng)效果:滾動(dòng)頻率由setTimeout(F,#%18?10:3000)這個(gè)3000來(lái)控制,感興趣的朋友可以了解下哦
具體代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>code.js.cn </title>
<style>
a
{
display: block;
font-size: 15px;
line-height: 18px;
text-decoration: none;
color: #333;
font-family: Arial;
font-size: 12px;
}
.shell
{
background:no-repeat 4px 5px;
border: 1px solid #aaa;
width: 400px;
padding: 3px 2px 2px 20px;
}
#div1
{
height: 36px;
overflow: hidden;
}
</style>
</head>
<body>
<div class="shell">
<div id="div1">
<a>這是</a>
<a>我的</a>
<a>第一篇</a>
<a>博客</a>
</div>
</div>
</body>
<script>
var c, _ = Function;
with (o = document.getElementById("div1")) { innerHTML += innerHTML; onmouseover = _("c=1"); onmouseout = _("c=0"); }
(F = _("if(#%18||!c)#++,#%=o.scrollHeight>>1;setTimeout(F,#%18?10:3000);".replace(/#/g, "o.scrollTop")))();
</script>
</html>
滾動(dòng)頻率由setTimeout(F,#%18?10:3000)這個(gè)3000來(lái)控制。
復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>code.js.cn </title>
<style>
a
{
display: block;
font-size: 15px;
line-height: 18px;
text-decoration: none;
color: #333;
font-family: Arial;
font-size: 12px;
}
.shell
{
background:no-repeat 4px 5px;
border: 1px solid #aaa;
width: 400px;
padding: 3px 2px 2px 20px;
}
#div1
{
height: 36px;
overflow: hidden;
}
</style>
</head>
<body>
<div class="shell">
<div id="div1">
<a>這是</a>
<a>我的</a>
<a>第一篇</a>
<a>博客</a>
</div>
</div>
</body>
<script>
var c, _ = Function;
with (o = document.getElementById("div1")) { innerHTML += innerHTML; onmouseover = _("c=1"); onmouseout = _("c=0"); }
(F = _("if(#%18||!c)#++,#%=o.scrollHeight>>1;setTimeout(F,#%18?10:3000);".replace(/#/g, "o.scrollTop")))();
</script>
</html>
滾動(dòng)頻率由setTimeout(F,#%18?10:3000)這個(gè)3000來(lái)控制。
相關(guān)文章
JavaScript組合拼接字符串的效率對(duì)比測(cè)試
這篇文章主要介紹了JavaScript組合拼接字符串的效率對(duì)比測(cè)試,本文測(cè)試了IE6、Firefox、Mozilla、Netscape、Opera等瀏覽器,需要的朋友可以參考下2014-11-11js實(shí)現(xiàn)跨域的幾種方法匯總(圖片ping、JSONP和CORS)
平時(shí)用慣了jQuery.ajax之類的方法,卻時(shí)常忽略了它背后的實(shí)現(xiàn),本文是學(xué)習(xí)了AJAX基礎(chǔ)及幾種跨域解決方案之后的一些收獲。2015-10-10使用post方法實(shí)現(xiàn)json往返傳輸數(shù)據(jù)的方法
今天小編就為大家分享一篇關(guān)于使用post方法實(shí)現(xiàn)json往返傳輸數(shù)據(jù)的方法,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2019-03-03Easy.Ajax 部分源代碼 支持文件上傳功能, 兼容所有主流瀏覽器
下面是Easy.Ajax類的初稿,如須發(fā)表,在代碼上還要修改以達(dá)到最簡(jiǎn),但API是不會(huì)變了2011-02-02淺析JavaScript中的變量復(fù)制、參數(shù)傳遞和作用域鏈
這篇文章主要介紹了淺析JavaScript中的變量復(fù)制、參數(shù)傳遞和作用域鏈 的相關(guān)資料,需要的朋友可以參考下2016-01-01JavaScript實(shí)現(xiàn)單英文金山打字通
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)單英文金山打字通,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-06-06