VS2008(C#)制作网页Tab标签切换方法(二)——JavaScript实现

 

使用JavaScript脚本代码,实现Tab标签切换

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Tab_JScript.aspx.cs" Inherits="TabContent" %>

<!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 runat="server">
    <title>Tab的JavaScript实现</title>
    <style type="text/css">
        body
        {
            color: #000000;
            background-color: #ffffff;
            font-family: Tahoma, 宋体;
            font-size: 12px;
            margin: 0px;
            padding: 0px;
            text-align: center;
        }
        .sec1
        {
            background-color: #99ffcc;
        }
        .sec2
        {
            background-color: #ffcc33;
        }
    </style>
</head>
<body>
    <form >
                <tr>
                    <td>
                        444-军事
                    </td>
                </tr>
            </tbody>
        </table>

        <script type="text/javascript">
            function secBoard(n) {
                for (i = 0; i < secTable.cells.length; i++)
                    secTable.cells[i].className = "sec1";
                secTable.cells[n].className = "sec2";
                for (i = 0; i < mainTable.tBodies.length; i++)
                    mainTable.tBodies[i].style.display = "none";
                mainTable.tBodies[n].style.display = "block";
            }
        </script>
    </center>
    </form>
</body>
</html>

 

 

具体代码如上,源代码下载: VS2008(C#)4种方法实现Tab标签灵活切换源码,测试成功!

相关文章: