如题,我在模态框里面使用editor的时候,第一次聚焦会导致模态框重新定位,若果模态框里包含滚动条,会导致重新回到顶部。debug之后发现是这一段代码导致的。问题是我不太明白他这么写的作用是什么?求大神解答
this.focus = function() {
if (tempStyle) return text.focus();
var top = text.style.top;
text.style.position = "fixed"
text.style.top = "-1000px";
text.focus();
setTimeout(function() {
text.style.position = "";
if (text.style.top == "-1000px")
text.style.top = top;
}, 0);
};