Xcode Tutorial: Inject Javascript Into Web View

preview_player
Показать описание
Learn how to inject lines of Javascript into your web view in Xcode.
Рекомендации по теме
Комментарии
Автор

The tutorial video is really helped me to understand the concept.

mbaskee
Автор

Good intro.  Thanks, will look for more from you.

tomgerry
Автор

In Swift 3 its much simpler. add an html doc to your root dir and post whatever script you want in it then use a webview with...

let url = Bundle.main.url(forResource: "logo", withExtension: "html")
let request = NSURLRequest(url: url!)
webView.loadRequest(request as URLRequest)

This is how you should go about it unless you need to reference app vars or data from the phone that js normally wouldn't access

VectorNodes
Автор

Hi, i'm trying to inject two NSUserdefaults into Username and a password field of a website in a webview. How can i do that?
The fields:

input class= "input" type="text" size="10" maxlenght="50" name="frmLoginMemberID" value=""

input class= "input" type="password" size="10" maxlenght="50" name="frmLogin2" value=""

username.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"usernamekey"];
password.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"passwordkey"];

zjem
Автор

if I wanted to save the javascript as a string directly, what do I do?

GreyMesaMedia
Автор

How old are you because you sound young?

nyjeltodd