Let’s explore this mysterious method with a couple of examples.
You would typically place this line of code in webViewDidFinishLoad.
Line 7 : Add the new <script> element as a child to the <head> element of the HTML DOM.
Bonus tip: You can break up NSString constants over multiple lines in Xcode for increased readability. Just end the line with a double-quote character and begin the next line with a double-quote character. At compile time these lines will be joined into one string. So the string that begins with “var script” on Line 1 is one continuous string ending with “appendChild(script);” on Line 7.
<html> <head> <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0"/> </head> <body> <p>This is the UIWebView</p> <form> <input id="field_1" type="text" name="value" /><br/> <input id="field_2" type="text" name="value" /><br/> <input id="field_3" type="text" name="value" /><br/> </form> </body> </html>