js新聞滾動 js如何實現(xiàn)新聞滾動效果
更新時間:2013年01月07日 17:34:15 作者:
JS實現(xiàn)新聞滾動效果:滾動頻率由setTimeout(F,#%18?10:3000)這個3000來控制,感興趣的朋友可以了解下哦
具體代碼如下:
<!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>
滾動頻率由setTimeout(F,#%18?10:3000)這個3000來控制。
復(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>
滾動頻率由setTimeout(F,#%18?10:3000)這個3000來控制。
相關(guān)文章
js實現(xiàn)跨域的幾種方法匯總(圖片ping、JSONP和CORS)
平時用慣了jQuery.ajax之類的方法,卻時常忽略了它背后的實現(xiàn),本文是學(xué)習(xí)了AJAX基礎(chǔ)及幾種跨域解決方案之后的一些收獲。2015-10-10使用post方法實現(xiàn)json往返傳輸數(shù)據(jù)的方法
今天小編就為大家分享一篇關(guān)于使用post方法實現(xiàn)json往返傳輸數(shù)據(jù)的方法,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-03-03Easy.Ajax 部分源代碼 支持文件上傳功能, 兼容所有主流瀏覽器
下面是Easy.Ajax類的初稿,如須發(fā)表,在代碼上還要修改以達(dá)到最簡,但API是不會變了2011-02-02淺析JavaScript中的變量復(fù)制、參數(shù)傳遞和作用域鏈
這篇文章主要介紹了淺析JavaScript中的變量復(fù)制、參數(shù)傳遞和作用域鏈 的相關(guān)資料,需要的朋友可以參考下2016-01-01