Is there a bug with using InnerHTML inside a UIWebView within a native iPhone application?

后端 未结 3 2142

I have a fairly large HTML/JS/CSS application that works great when running as a web application with Safari on the iPhone.

When running this same application in an UIWe

3条回答
  •  抹茶落季
    2021-02-08 10:46

    I had this problems too. It happens when the CPU of the phone is very busy (say 100%). Then the rendering engine sometimes forget about innerHTML settings.

    The solution included in my unify project is to test if there is an element in childNodes, otherwise apply it again.

    var target = document.createElement("div");
    var text = "
    Hello World
    "; target.innerHTML = text; var self = this; self.__intervalHandle = window.setInterval(function() { target.innerHTML = text: if (target.firstChild) { window.clearInterval(self.__intervalHandle); self.__intervalHandle = null; } }, 100);

    This forces the rendering engine to apply the innerHTML to the DOM and gives the rendering engine some time (100 ms in this example, a good value in our tests) to handle it.

提交回复
热议问题