I’m creating a “web loader” for an iphone app. An html file is bundled with the iphone app and loaded into a webview. In webViewDidFinishLoad i use stringByEvaluatingJavascriptFromString to execute a javascript function that creates an iframe, waits for it to load and then transitions it onto the screen. It seems the process of creating the iframe causes webViewDidFinishLoad to constantly be called over and over and over again. Has anyone experienced this problem or have a tip to identify how i might create an iframe via javascript without triggering this bug?
HTML file js code looks like so:
var ifrm;
function load(url) {
ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", url);
ifrm.style.width = "100%";
ifrm.style.height = "100%";
ifrm.style.display = "none";
ifrm.onload = function () {
document.getElementById('loading').style.display = 'none';
ifrm.style.display = '';
}
document.body.appendChild(ifrm);
}
My problem was that the iframe created in javascript was causing a second webViewDidFinishLoad method to fire. I was incorrectly calling my js function again in this method which would cause a new iframe to be created and cause the looping behaviour. I simply ignored the second call of this method and everything worked as expected.