access to xmlhttprequest at 'file ///' from origin 'null' has been blocked by cors policy code example

Example 1: javascript access to xmlhttprequest at from origin 'null' has been blocked by cors policy

//Open the HTML file using live server, it will work

Example 2: access to image at from origin

//use crossorigin="anonymous" sttribute in img tag

<img src="https://upload.wikimedia.org/wikipedia/commons/f/f9/Phoenicopterus_ruber_in_S%C3%A3o_Paulo_Zoo.jpg" id="external-flamingo" crossorigin="anonymous">

Tags:

Html Example