天天看點

類似marquee的滾動資訊顯示

 <!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>

    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

    <title>滾動廣告資訊</title>

    <style type="text/css">

        #nli_con

        {

            height: 200px;

            width: 400px;

            overflow: hidden;

            border: 1px solid #999999;

        }

        div, dl, dt, dd

            margin: 0px;

            padding: 0px;

        dl

            padding-top: 5px;

            padding-bottom: 5px;

            border-bottom-width: 1px;

            border-bottom-style: solid;

            border-bottom-color: #CCCCCC;

            font-size: 14px;

            margin-right: 10px;

            margin-left: 10px;

        dd

            font-size: 12px;

    </style>

    <script language="javascript" type="text/javascript">

        function myMarquee(id, name, out, speed) {

            var $ = function (d) {

                typeof d == "string" && (d = document.getElementById(d));

                return $.fn.call(d);

            };

            $.fn = function () {

                //附加2個方法 

                this.$ADD = function (fn) { CLS.add(this, fn) };

                this.addEvent = function (sEventType, fnHandler) {

                    if (this.addEventListener) { this.addEventListener(sEventType, fnHandler, false); }

                    else if (this.attachEvent) { this.attachEvent("on" + sEventType, fnHandler); }

                    else { this["on" + sEventType] = fnHandler; }

                }

                this.removeEvent = function (sEventType, fnHandler) {

                    if (this.removeEventListener) { this.removeEventListener(sEventType, fnHandler, false); }

                    else if (this.detachEvent) { this.detachEvent("on" + sEventType, fnHandler); }

                    else { this["on" + sEventType] = null; }

                return this;

            var Class = { create: function () { return function () { this.initialize.apply(this, arguments); } } };

            var Bind = function (obj, fun, arr) { return function () { return fun.apply(obj, arr); } }

            var Marquee = Class.create();

            Marquee.prototype = {

                initialize: function (id, name, out, speed) {

                    this.name = name;

                    this.box = $(id);

                    this.out = out;

                    this.speed = speed;

                    this.d = 1;

                    this.box.style.position = "relative";

                    this.box.scrollTop = 0;

                    var _li = this.box.firstChild;

                    while (typeof (_li.tagName) == "undefined") _li_li = _li.nextSibling;

                    this.lis = this.box.getElementsByTagName(_li.tagName);

                    this.len = this.lis.length;

                    for (var i = 0; i < this.lis.length; i++) {

                        //計算該複制多少節點,保證無縫滾動,沒必要的就不複制 

                        var __li = document.createElement(_li.tagName);

                        __li.innerHTML = this.lis[i].innerHTML;

                        this.box.appendChild(__li);

                        if (this.lis[i].offsetTop >= this.box.offsetHeight) break;

                    }

                    this.Start();

                    this.box.addEvent("mouseover", Bind(this, function () { clearTimeout(this.timeout); }, []));

                    this.box.addEvent("mouseout", Bind(this, this.Start, []));

                },

                Start: function () {

                    clearTimeout(this.timeout);

                    var me = this;

                    this.timeout = setTimeout(function () { me.Up() }, this.out * 1000)

                Up: function () {

                    clearInterval(this.interval);

                    this.interval = setInterval(function () { me.Fun() }, 10);

                Fun: function () {

                    this.box.scrollTop += this.speed;

                    if (this.lis[this.d].offsetTop <= this.box.scrollTop) {

                        clearInterval(this.interval);

                        this.box.scrollTop = this.lis[this.d].offsetTop;

                        this.Start();

                        this.d++;

                    if (this.d >= this.len + 1) {

                        this.d = 1;

                        this.box.scrollTop = 0;

            var m = new Marquee(id, name, out, speed);

        window.onload = function () { myMarquee("nli_con", "marquee", 2, 2) } 

    </script>

</head>

<body>

    <div id="nli_con">

        <dl>

            <dt><a href="http://www.hwj123.com/" target='_blank'><strong>1. 域名與網址有什麼差別?</strong></a></dt>

            <dd>

                一個完整網址範例如下: http://www.hwj123.com....</dd>

        </dl>

            <dt><a href="http://www.hwj123.com/blog/post/8.html" target='_blank'><strong>2. 什麼是虛拟主機?

            </strong></a></dt>

                虛拟主機是使用特殊的軟硬體技術,把一台運作在網際網路上的伺服器主機分成一台台“虛拟”的主機,每一台虛拟主機都具有獨立的域名,具有完整的Internet伺服器(WWW、FTP、Email等)功能,虛拟主機之間完全獨立,并可由使用者自行管理,在外界看來,每一台虛拟主機和一台獨立的主機完全一樣。迅捷主機網為中小客戶提供優質的網絡環境和伺服器,并由進階網管負責監控。</dd>

            <dt><a href="http://www.hwj123.com/blog/post/45.html" target='_blank'><strong>3. 關于中小企業網站建設的知識</strong></a></dt>

                中小企業一直是企業上網工程主要服務的對象,中小企業上網的效果總是“猶抱琵琶半遮面”顯現不出什麼效果,本站整理了多年對中小企業服務的經驗...</dd>

            <dt><a href="http://www.hwj123.com/blog/post/42.html" target='_blank'><strong>4. 為什麼要建立網站标準?什麼是網站标準?</strong></a></dt>

                我們大部分人都有深刻體驗,每當主流浏覽器版本的更新,我們剛建立的網站就可能變得過時,我們就需要更新或者重建立造一遍網站。例如1996-1999年典型的</dd>

            <dt><a href="http://www.hwj123.com/blog/post/22.html" target='_blank'><strong>5. 企業網站建設須注意的10大問題</strong></a></dt>

                企業網站已經成為一個企業網際網路戰略的基礎,有人說:"10年以後,網際網路業将消失。"...</dd>

            <dt><a href="http://www.hwj123.com/blog/post/30.html" mce_href="http://www.hwj123.com/blog/post/30.html"

                target='_blank'><strong>6. 2009牛年,網站怎樣發展好</strong></a></dt>

                第一,選擇做網站内容, 制定網站内容,根據你的團隊工作能力,工作量接受範圍度等等,制定一個架構性的簡單的方案。 最好能發揮自己的專長,如果你是三國裡的張飛...</dd>

            <dt><a href="http://www.hwj123.com/blog/post/13.html" mce_href="http://www.hwj123.com/blog/post/13.html"

                target='_blank'><strong>7. Internet域名是什麼??</strong></a></dt>

                Internet域名,是Internet網絡上的一個伺服器或一個網絡系統的名字,在全世界,沒有一個重複的域名。域名的形式是以若幹個英文字母和數字組成,由...</dd>

    </div>

</body>

</html>