[JavaScript]XP菜單效果

來源:互聯網
上載者:User
應大家所說的,沒把注釋貼出來!

其實代碼很簡單,只是些JavaScript而已。

好了,現在修改了一下。

==============

HTML 程式碼: (直接複製粘貼成.htm就可以看到效果了!)

==============

<html>

    <head>

        <title></title>

        <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">

        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">

            <!-- 定義預設的style值 -->

        <style>

            .menu td

            {

                font-size:12px;

                font-family:verdana,arial;

                font-weight:bolder;

                color:#ffffff;

                border:1px solid #336699;

                background:#336699;

                filter:blendtrans(duration=0.5);

                cursor:hand;

                text-align:center;

            }

        </style>

        <script language="javascript">

            function Menu(objid)

            {

                var tds=objid.getElementsByTagName('td');        //定義個對像。該對像所指為Table內的所有td。

                for(var i=0;i<tds.length;i++)         //迭代出所有td

                {

                    with(tds[i])

                    {

                        onmouseover=function()              //滑鼠移入時

                        {

                            with(this)

                            {

                                filters[0].apply();            //慮鏡

                                style.background='#66CCFF';           //背景色

                                style.border='1px solid #ffffff';          //邊框style

                                style.color='black';             //字型色

                                filters[0].play();

                            }

                        }

                        onmouseout=function()        //滑鼠移出時

                        {

                            with(this)

                            {

                                filters[0].apply(); 

                                style.background='#336699';              //背景色

                                style.border='1px solid #336699';           //邊框style

                                style.color='#ffffff';           //字型色

                                filters[0].play();

                            }

                        }

                    }

                }

            }

        </script>

    </head>

    <body>

        <table class="menu" id="TestMenu" width="400" cellpadding="1" cellspacing="2" border="0"

            bgcolor="#336699" align="center">

            <tr>

                <td>HD</td>

                <td>HD</td>

                <td>HD</td>

                <td>HD</td>

            </tr>

            <tr>

                <td>HD</td>

                <td>HD</td>

                <td>HD</td>

                <td>HD</td>

            </tr>

            <tr>

                <td>HD</td>

                <td>HD</td>

                <td>HD</td>

                <td>HD</td>

            </tr>

            <tr>

                <td>HD</td>

                <td>HD</td>

                <td>HD</td>

                <td>HD</td>

            </tr>

        </table> 

            <!-- 函數調用,參數TestMenu為Table的ID值! -->

        <script>Menu(TestMenu);</script>

    </body>

</html>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.