0

I'm building a javascript script which will be used in a iOS shortcuts task for myself. The code will run in a safari webview to pull some data from a website source code.

I'm developing the script on the computer, using Chrome to test it. Basically when I try to load a website with jQuery $.load() I get a cross-origin error in chrome console. How can I overcome this? I know it can be done by allowing it through HTTP headers, but this script will run without any server, so is there another way to tell the browser to allow this?

The exact error is: CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

SebaSbs
  • 343
  • 1
  • 2
  • 11
  • No, you can't. Most browsers treat `file://` URLs as origin `null`, and you can't authorize origin `null` with CORS (and even if you could, it would be the **other site** that would need to do it). – T.J. Crowder May 10 '21 at 07:19
  • // if you are just want to redirect or load the web page, you can use the following methods for that. window.location.href = "http://www.example.com"; window.location.replace("http://www.example.com"); – Sachin Liyanage May 10 '21 at 07:23

0 Answers0