0

The following line of code works but returns the HTML code before executing the java scripts in the page.

var myContent = String(contentsOfURL: NSURL(string: myURL)!, encoding: NSUTF8StringEncoding, error: nil) as String!

I've been researching this for a while but I'm having a hard time filtering out all the iOS noise (any advise on this would be highly appreciated).

Gio
  • 65
  • 1
  • 1
  • 7

1 Answers1

0

JavaScript code embedded in HTML is meant to be executed by a rendering engine such as a browser. when you download a HTML file (using String(contentsOfURL...)) you are doing exactly that - downloading the HTML file. There is no execution.

Once you download the file, you can then render the HTML file (for example, by loading it in a UIWebView - see How to load local html file into UIWebView for an example). Rendering the HTML file will "execute" the JavaScript based on how the HTML+JavaScript is authored.

Community
  • 1
  • 1
tng
  • 4,286
  • 5
  • 21
  • 30