使用谷歌浏览器浏览器在osX上的奇怪功能行为

时间:2011-11-28 22:26:02

标签: javascript html css macos google-chrome

此文本区域是一个自动扩展文本区域,当它是4行的高度时停止扩展。

mac problem http://dl.dropbox.com/u/8196173/mac_problem.PNG windows version http://dl.dropbox.com/u/8196173/windows_version.PNG

左边的那个是如何使用Google Chrome在Mac上显示文本框,右边的文本框是如何在Windows上显示的。 Windows版本是正确的。由于某些原因,每次扩展时,Chrome上的chrome都不会向文本区域添加相同的高度,这意味着它最终变小,因此底部有额外的空间。但对于我的生活,我不知道为什么它会像这样只是因为它在不同的操作系统上。

我可以包含代码,如果人们真的想要它,但它几乎一百行(当它扩展时页面上还有其他东西被移动)我真的不知道它是如何成为代码,因为它适用于Windows并且只表现出osX上的奇怪行为。

编辑:这会发生在Chrome扩展程序中,以防有所作为。

    var temp = 0;
    //function that actually handles the resizing
        function resize() {
            temp = text.style.height;
            text.style.height = 18;
            text.style.height = text.scrollHeight + 'px';
            var styledef = window.getComputedStyle(text);
            pixelMargin = parseInt(styledef.marginTop, 10);
            num = parseInt(container.style.height, 10);
            re_num = parseInt(reply_container.style.marginTop, 10);
            var temp_num = parseInt(temp, 10);
            text_height = parseInt(text.style.height, 10);
            if(temp_num == 0) { //if nothing has been done in the text area do this
                temp = text.style.height;
            } else if(text_height == 18) { //else if the text area is only one line do this
                text.style.marginTop = '3';
                reply_container.style.marginTop = '0px';
                container.style.height = '364px';
                container.scrollTop = container.scrollHeight;
            } else if(temp_num < text_height) { //else the box is getting bigger 
                if(text_height <= 66 ) {
                    pixelMargin -= 15;
                    num -= 16;
                    re_num += 16;
                    conversation_scroll_pos += 16;
                    text.style.marginTop = pixelMargin.toString() + 'px';
                    container.style.height = num.toString() + 'px';
                    reply_container.style.marginTop = re_num.toString() + 'px';
                    container.scrollTop = container.scrollHeight;
                    temp = text.style.height;
                } else if(text_height >= 66 && temp_num > 20) { //case where the box has reached its max height and the user is still typing
                    temp = text.style.height;
                } else if(text_height > 66 && pixelMargin == 3) { //edge case to handle cuting and pasting into the box
                    text.style.marginTop = '-42px';
                    reply_container.style.marginTop = '48px';
                    container.style.height = '316px';
                    container.scrollTop = container.scrollHeight;
                    temp = text.style.height;
                }
            } else if(temp_num > text_height) { //else the box is getting smaller
                if(pixelMargin < 3 && pixelMargin >= -45 && text_height < 66) {
                    pixelMargin += 15;
                    num += 16;
                    re_num -= 16;
                    text.style.marginTop = pixelMargin.toString() + 'px';
                    container.style.height = num.toString() + 'px';
                    reply_container.style.marginTop = re_num.toString() + 'px';
                    temp = text.style.height;
                }
            }

        }

0 个答案:

没有答案