我想通过Javascript控制IE浏览器自带的滚动条的显示和隐藏,以下代码在IE7、IE8和FF中通过,但在IE6中出问题,无法隐藏IE6自带的滚动条,显示时却又多出来一条滚动条,如下图: <script language="javascript" type="text/javascript"> 
document.body.style.overflow = "hidden"; 
document.body.style.overflow = "scroll"; 
</script> 页面中没有任何DIV或IFrame,就是 <body> </body>,请大家帮忙看看应该如何解决在IE6中通过Javascrip控制IE浏览器自带的滚动条的显示和隐藏,100分送上!! 

解决方案 »

  1.   

    楼上的无效,我的网页头是:
    <!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">
      

  2.   

    完整的网页代码,在IE7、IE8,FF中可以,但在IE6中不行。<!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></head>
    <body>
    <li>01</li><li>02</li><li>03</li><li>04</li><li>05</li><li>06</li><li>07</li><li>08</li>
    <li>09</li><li>10</li><li>11</li><li>12</li><li>13</li><li>14</li><li>15</li><li>16</li>
    <li>17</li><li>18</li><li>19</li><li>20</li><li>21</li><li>22</li><li>23</li><li>24</li>
    <li>25</li><li>26</li><li>27</li><li>28</li><li>29</li><li>30</li><li>31</li><li>32</li>
    <li>33</li><li>34</li><li>35</li><li>36</li><li>37</li><li>38</li><li>39</li><li>40</li>
    <li>41</li><li>42</li><li>43</li><li>44</li><li>45</li><li>46</li><li>47</li><li>48</li><p></p>
    <a href="javascript:aaa();">隐藏滚动条</a><p></p><a href="javascript:bbb();">显示滚动条</a></body>
    </HTML>
    <script>
    function aaa()
    {
        document.body.style.overflow = "hidden"
    }
    function bbb()
    {
        window.document.body.style.overflow='scroll'
    }
    </script>
      

  3.   

    没有 IE 6,lz 试试看,行了就给分哈L@_@K
    <!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> new document </title>
      <meta name="generator" content="editplus" />
      <meta name="author" content="" />
      <meta name="keywords" content="" />
      <meta name="description" content="" />
     </head> <body>
    <input type="button" value="Go" id="btnGo" />
      <script type="text/javascript">
      <!--
    // For IE 6
    document.body.style.overflow = "auto";
    // For IE 7 or 8
    document.documentElement.style.overflow = "auto";document.getElementById("btnGo").onclick = function() {
    for (var i=0; i<200; i++)
    {
    document.body.appendChild(document.createElement("hr"));
    }
    };
      //-->
      </script>
     </body>
    </html>
      

  4.   

    <body scroll='no'> 
    这样试试
      

  5.   

    lz 在 #3 的代码在 IE 7 下根本无效!改成这样才行!L@_@K
    function aaa()
    {
        document.body.style.overflow = "hidden";
        document.documentElement.style.overflow = "hidden";
    }
    function bbb()
    {
        document.body.style.overflow = "scroll";
        document.documentElement.style.overflow="scroll";
    }
      

  6.   


    <body STYLE='OVERFLOW: SCROLL; OVERFLOW-Y: HIDDEN'; OVERFLOW-Y: HIDDEN'>