toadpeng's profilebenhur的书房PhotosBlogLists Tools Help

Blog


    October 09

    IE在改变下拉菜单的背景色时的一个BUG

        当option的数量比select box的size小的时候(例如,当一个select box中的option只有4个而select box的size为8时),这时候如果改变select box的背景色,在IE中会表现为:select box中被option覆盖的那部分的背景色正常地发生了改变,其他部分保持不变。(如下图所示)

    select box的背景色最初为红色:


    点击button变为白色:


        发生这种情况方并不是因为背景色变更时只改变了option的背景色,实际上整个select box的背景色都已经改变了,只是select box中没有被option覆盖的区域没有被重绘而已。这时只要将任何一个windows窗口移动到select box上然后移开,select box被windows窗口覆盖过的区域就会正常地显示变更后的背景色。(如下图)

    将一个对话框移到select box上:


    移开后,被覆盖的部分正常显示为白色:


        在Firefox中不存在这个问题。

    源代码:
    <html>
    <head>
    <title>changing <select> background color</title>
    <script language="javascript">
    function foo()
    {
     document.getElementById("ListBoxC4").style.backgroundColor = "white";
    }
    </script>
    </head>
    <body>
    <select size="8" id="ListBoxC4" style="background-color:red;">
     <option value="1">AAAAA</option>
     <option value="2">BBBBB</option>
     <option value="3">CCCCC</option>
     <option value="4">DDDDD</option>
    </select>
    <input type="button" name="ButtonChangeColor" value="ButtonChangeColor" onclick="foo();"/>
    </body>
    </html>

    Comments (2)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Picture of Anonymous
    benhur wrote:
    关于悬浮窗的文章,说具体实现方法的能找到一些,讲绘制原理还真没有,跟这个BUG联系起来的更是没有了……
    Oct. 10
    Picture of Anonymous
    Sight wrote:
    呵呵,有意思,试了下,几乎所有的界面只要有覆盖就都成了橡皮擦,除了flashget或迅雷的悬浮窗,可能悬浮窗与鼠标图形的显示同理,点解?
    Oct. 10

    Trackbacks

    The trackback URL for this entry is:
    http://toadpeng.spaces.live.com/blog/cns!6489D81CFC135717!340.trak
    Weblogs that reference this entry
    • None