As I understand the attribute crossorigin - to process requests from other sources. Re-read the Internet, so plainly and did not understand the meaning of the attribute. Is it needed if I want to take and upload a picture from another site to my site? What do I need for this, in src specify the address of this picture and use the crossorigin attribute? Attribute values ​​do not understand what they mean:

 anonymous use-credentials 

Can anybody explain the principle of the attribute?

For example, a code, why doesn’t a picture from another site appear? What value should be added to the attribute for the picture to appear?

  <body> <div> <img src="http://russian7.ru/wp-content/uploads/2014/07/20130215184904.jpg" crossorigin=""> </div> </body> 

1 answer 1

crossorigin
This attribute determines whether CORS is used when loading an image. Images loaded using CORS can be used in elements without limiting the functionality of the latter (English tainted canvas).
This attribute has 2 valid values:
anonymous
In this case, before downloading the image, a cross-origin request is executed (i.e., a Origin: HTTP header is used). However, the access parameters are not transmitted (neither a cookie, nor an X.509 certificate, nor a login / password for basic HTTP authentication). The server response must contain an Access-Control-Allow-Origin: HTTP header, otherwise the use of the image is restricted.
use-credentials
Before the image is loaded, a cross-origin request (Origin: HTTP header) is executed, indicating the access parameters (in the form of a cookie, a certificate or a login / password pair). The server response must contain an Access-Control-Allow-Origin: HTTP header, otherwise the use of the image is restricted. If this attribute is not specified, CORS is not used when loading an image (there is no Origin: HTTP header), and the use of the image in is always limited. If the attribute value is incorrect (for example, if there is a typo), the value is anonymous. For more information, see the article CORS settings attributes .
A source

  • I did not understand something. So, do I understand correctly that you can use it to upload a picture from another site to your site? What do I need for this, in src, specify the address of this picture and use the crossorigin attribute? - Pavel Igorev