NeoWang
NeoWang

Reputation: 18513

How to inject javascript into a web page loaded in UIWebView?

I need to load a web page from an independent website in my iOS app, however, the webpage is not optimized for mobile experience. I want to execute some js to re-layout the page after it is loaded.

  1. Is this possible?
  2. How shall I do it so that users don't see the original page, only the re-layouted version?

Upvotes: 0

Views: 220

Answers (1)

oiledCode
oiledCode

Reputation: 8649

The most basic way to inject your JS is using the following UIWebView method

- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script

Upvotes: 1

Related Questions