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)文章
詳解JavaScript基于面向?qū)ο笾畡?chuàng)建對象(1)
這篇文章主要介紹了JavaScript基于面向?qū)ο笾畡?chuàng)建對象,對創(chuàng)建對象進行了詳細描述,感興趣的小伙伴們可以參考一下2015-12-12
javascript對HTML字符轉(zhuǎn)義與反轉(zhuǎn)義
這篇文章主要介紹了javascript對HTML字符轉(zhuǎn)義與反轉(zhuǎn)義,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-12-12
JavaScript實現(xiàn)圖片上傳并預(yù)覽并提交ajax
這篇文章主要為大家詳細介紹了JavaScript實現(xiàn)圖片上傳并預(yù)覽并提交ajax,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-09-09
xmlplus組件設(shè)計系列之圖標(ICON)(1)
這篇文章主要為大家詳細介紹了xmlplus組件設(shè)計系列之圖標ICON的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-05-05
JS操作XML實例總結(jié)(加載與解析XML文件、字符串)
這篇文章主要介紹了JS操作XML的方法,結(jié)合實例形式總結(jié)分析了JavaScript加載與解析XML文件及字符串的相關(guān)技巧,需要的朋友可以參考下2015-12-12

