I’ve got an iPhone app and an iPad app, both running the same web code inside a UIWebView.
The web code is a call to a PHP page to get some HTML + Javascript to the mobile and display it inside a frame.
The purpose of this code is to interact with a chat server.
The HTML includes a DIV:
<div id="messageContainer" style="width: 768; height: 310; border: 1px solid black; background-color: black; color: white; font-size: 14px; overflow: auto; -webkit-overflow-scrolling:touch">
</div>
When the javascript code gets a line of data from the server, it simply adds it to the div:
function addPost(data) {
var e = document.getElementById("messageContainer");
var post;
if (typeof(data) == "object")
{
post = "<div dir='ltr'><span style='color: rgb(183,226,76)' >" +
data.displayName + "</span>‎: " +
"<span >" + data.msg + "</span><BR/></div>";
} else {
post = data + "<BR/>";
}
e.innerHTML = post;
e.scrollTop = e.scrollHeight;
}
So the text in the div is scrolled to keep in view.
Both iPhone and iPad are running iOS 5.
The application works perfectly on the iPhone!
However, on the iPad, aafter about 20-25 lines of data, the div no longer displays new text.
I checked the value of innerHTML, and it does indeed include the new text. It just refuses to display it.
I can scroll the text in that case, but can’t add new text that will show.
I’ve read several posts about problems with scrolling and innerHTML on iPad, but none of the suggested solutions helped.
Any idea on what might be wrong would greatly appreciated!
Thx
Ofer
UPDATE #1:
The HTML body is:
<body style="margin: 0px; height: <?=$chatWindowHeight?>;">
<div id="messageContainer" style="width: <?=$chatWindowWidth?>; height: <?=$chatWindowHeight?>; border: 1px solid black; background-color: black; color: white; font-size: 14px; overflow: auto; -webkit-overflow-scrolling:touch">
</div>
<IFRAME name="chatwindow2" id="chatwindow2" FRAMEBORDER="0" SCROLLING="NO" WIDTH="0" HEIGHT="0" src="ConnectToChat.php">Browser does not support iframes!</IFRAME>
</body>
Just for the record, it turned out that the issue was in the iPad application and the way it implemented scrolling (I don’t own that code, just the web part).
Once the owner fixed the app, things started working as expected.
Anyway, thanks to all who answered my question, much appreciated!