Search code examples
javascriptiosiphoneuiwebviewepub

Remove images from UIWebview


In my iPhone app, an epub reader, based off the method here, I have parsed the epub, created the UIWebviews, but I have a slight problem. There are images in the epubs that are larger than the width of the iPhone's screen (320 px.). Is there a Javascript method I can invoke on the UIWebview ([view stringByEvaluatingJavaScriptFromString:SomeJavaScriptString]) and remove those images programatically without changing the epub manually?

UPDATE: Could the issue be that the source file is an xml file and not HTML?


Solution

  • You probably want something like: document.getElementById('id_of_your_image').style.visibility = 'hidden'

    UPDATE To hide all images in a document,

    for (i=0; i<document.getElementsByTagName("img").length; i++) {
        document.getElementsByTagName("img")[i].style.visibility = 'hidden';
    }
    

    should do the trick.