Javascript google chrome浏览器在osX上的wierd函数行为

Javascript google chrome浏览器在osX上的wierd函数行为,javascript,html,css,macos,google-chrome,Javascript,Html,Css,Macos,Google Chrome,此文本区域是一个自动展开的文本区域,当其高度为4行时停止展开 因此,左边的一个是文本框在mac和Google chrome上的显示方式,右边的一个是它在windows上的显示方式。windows版本是正确的。由于某些原因,mac上的chrome在每次扩展时不会向文本区域添加相同的高度,这意味着它最终会变小,从而在底部增加额外的空间。但就我个人而言,我不知道为什么它会这样,仅仅因为它在不同的操作系统上 如果人们真的需要,我可以包含代码,但它几乎有一百行(当它扩展时,页面上还有其他东西在移动),我

此文本区域是一个自动展开的文本区域,当其高度为4行时停止展开

因此,左边的一个是文本框在mac和Google chrome上的显示方式,右边的一个是它在windows上的显示方式。windows版本是正确的。由于某些原因,mac上的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;
                }
            }

        }
var-temp=0;
//实际处理大小调整的函数
函数resize(){
temp=text.style.height;
text.style.height=18;
text.style.height=text.scrollHeight+'px';
var styledef=window.getComputedStyle(文本);
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);
如果(temp_num==0){//如果在文本区域中未执行任何操作,请执行此操作
temp=text.style.height;
}else如果(text_height==18){//else如果文本区域只有一行,则执行此操作
text.style.marginTop='3';
回复_container.style.marginTop='0px';
container.style.height='364px';
container.scrollTop=container.scrollHeight;
}else如果(temp\u num20){//框已达到最大高度且用户仍在键入
temp=text.style.height;
}否则,如果(text_height>66&&pixelMargin==3){//edge case处理剪切和粘贴到框中的操作
text.style.marginTop='-42px';
回复_container.style.marginTop='48px';
container.style.height='316px';
container.scrollTop=container.scrollHeight;
temp=text.style.height;
}
}else如果(temp\u num>text\u height){//else框变小了
如果(像素边距<3&&pixelMargin>=-45&&text\u高度<66){
像素边缘+=15;
num+=16;
re_num-=16;
text.style.marginTop=像素margin.toString()+'px';
container.style.height=num.toString()+'px';
reply_container.style.marginTop=re_num.toString()+'px';
temp=text.style.height;
}
}
}

我已经在Chrome的两个操作系统上成功地实现了这类功能,所以这一定是您的具体实现。这意味着我们需要查看代码。如果是100行,就把它裁剪成相关的部分。@maxedison我包括了代码。我也这样做过,只是不在chrome扩展中,正如我在mac和windows之间的chrome扩展中看到的其他奇怪行为一样,我更倾向于相信这是浏览器的错,而不是我的错,因为函数所做的只是数学,我从检查员那里知道,这只会在mac上增加一半的高度。如果这是一个一致的问题(也就是说,在mac电脑上的高度总是一半),如果用户在mac电脑上,为什么不进行调整呢?