Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
292 views
in Technique[技术] by (71.8m points)

javascript - 使用removeChild后如何解决越野车滚动(how to solve buggy scrolling after using removeChild)

So there is this webpage:

(所以有这个网页:)

<body class="" style="overflow: hidden;">
    <div> <!-- stuff --> </div>
    <div class="AbCde Zy1XW   ">
        <!-- unwanted crap -->
    </div>
</body>

I want to remove class="AbCde Zy1XW " and style="overflow: hidden;"

(我想删除class="AbCde Zy1XW "style="overflow: hidden;")

from body so I used this code:

(从body所以我用下面的代码:)

  d=document
  e=d.getElementsByClassName("AbCde Zy1XW   ")[0];
  e.parentNode.removeChild(e);
  document.querySelector('body').removeAttribute('style');

It works but the problem is that the scrolling of the webpage is buggy on iOS.

(它可以工作,但问题是在iOS上网页的滚动存在问题。)

You have to zoom in and out before you can scroll normally.

(您必须先放大和缩小,然后才能正常滚动。)

But after a while, you can't scroll anymore and need to do the zoom out/zoom in trick again.

(但是过了一会儿,您将无法滚动,需要再次进行缩小/放大技巧。)

Any ideas why?

(有什么想法吗?)

Thanks

(谢谢)

EDIT:(编辑:)

Using remove();

(使用remove();)

also has this same issue...

(也有同样的问题...)

  ask by wolnavi translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...