Best way to put javascript in an xcode project

I have a javascript function that is currently located in an html file. And in my xcode project, I have a button related to UIWEBVIEW (linked to my local html file that has javascript).

The code is inside my html file.

<script type="text/javascript"> var now = new Date(); var day = now.getDate(); if (day % 2 == 0) alert("Today is Day 2"); else alert("Today is Day 1"); </script> 

It currently displays what I want, but the only problem is that the warning header displays day.html. Anyway, I can use the xcodes UIAlert function, but with my javascript?

Here is the image:

enter image description here

+4
source share
2 answers

I found the answer! For someone interested, they can find it in the link below ..

NSString in UIWebview

0
source

You cannot change the title inside the UIWebView, however you can do some nasty tricks like How to call Objective-C from Javascript? to accomplish what you want.

+1
source

Source: https://habr.com/ru/post/1387838/


All Articles