The crossorigin
attribute sets the mode of the request to an HTTP CORS Request.
Web pages often make requests to load resources on other servers. Here is where CORS comes in.
A cross-origin request is a request for a resource (e.g. style sheets, iframes, images, fonts, or scripts) from another domain.
CORS is used to manage cross-origin requests.
CORS stands for Cross-Origin Resource Sharing, and is a mechanism that allows resources on a web page to be requested from another domain outside their own domain. It defines a way of how a browser and server can interact to determine whether it is safe to allow the cross-origin request. CORS allows servers to specify who can access the assets on the server, among many other things.
Tip: The opposite of cross-origin requests is same-origin requests. This means that a web page can only interact with other documents that are also on the same server. This policy enforces that documents that interact with each other must have the same origin (domain).
Tip: Also look at the integrity
attribute.
The numbers in the table specify the first browser version that fully supports the attribute.
<script crossorigin="anonymous|use-credentials">
Value | Description |
---|---|
anonymous use-credentials |
Specifies the mode of the CORS request:
|
Category: | Web Tutorial |
Sub Category: | HTML Tag |
Uploaded by: | Admin |