How can I include a js file from iCloud in a rendered html file in webview

I’m interested in creating a script that allows me to is a js file from iCloud in my html. Also can this be don’t locally where as the file is saved in the actual script? Please assist.

You can try this:

      var script   = document.createElement('script');
      script.type  = 'text/javascript';
      script.async = 'async';
      script.src   = 'http://myserver/my script path/myscript.js';
      document.body.appendChild(script);

However you may run into the same-origin policy security permission (https://en.wikipedia.org/wiki/Same-origin_policy). Basically the site may not allow scripts coming from another domain. Most large sites enable the same-origin policy.

–Scott.

1 Like

Thanks unfortunately this is not working

Can you provide details of what you are using on the Scriptable side, what you are including, and what you are getting currently?

VexTab-div.js is the file I want to use in my HTML

Let html = “

<body Some html “””

That’s only a hint at what you have. It doesn’t even show how you have implemented the suggested solution above.

Can you share the details? It is orders of magnitude harder to help without being able to see the whole picture.

2 Likes