0

I want to write a Javascript in a standard location and connect this file to a page html.

Write: (using Swift 1.2)

let path = NSTemporaryDirectory() + "foo.js"
    var error: NSError?
    text = "12345"
    text.writeToFile(path, atomically: true, encoding: NSUTF8StringEncoding, error: &error)

html:

<html>
<head>
    <script src="path/foo.js"></script>
</head>
<body>
   <p> Use Foo </p>

</body>

Which path i can use?

  • you can use javscript in the above approach , but while setting url to to webview user `relativetopath:` as javascript file location – Vinodh Nov 21 '16 at 07:43
  • or you can try like this http://stackoverflow.com/a/34206714/1142743 – Vinodh Nov 21 '16 at 07:45

0 Answers0