HTML DOM Link crossOrigin Property
Last Updated :
22 Aug, 2022
The HTML DOM Link crossOrigin property is used to set or return the value of the crossorigin attribute of the <link> element. This attribute is used for specifying the HTTP CORS request when fetching or loading the stylesheet or icon files from the third-party server.
Syntax:
- It returns the cross-origin property.
linkObject.crossOrigin;
- It is used to set the cross-origin property.
linkObject.crossorigin="anonymous | use-credentials;
Property values:
- anonymous: It has a default value. It defines a CORS request will be sent without passing the credentials information.
- use-credentials: A cross-origin request will be sent with credentials, cookies, and certificate.
Example 1: Below HTML code returns the link cross-origin property.
HTML
<!DOCTYPE html>
< html >
< head >
< link id = "linkid" rel = "stylesheet" type = "text/css"
href = "styles.css" sizes = "16*16"
hreflang = "en-us" crossorigin = "use-credentials" >
</ head >
< body style = "text-align:center;" >
< h1 style = "color:green" >
GeeksforGeeks
</ h1 >
< strong >DOM Link crossOrigin property</ strong >
< br />< br />
< button onclick = "myClick()" >
return
</ button >
< p id = "pid" style = "font-size:25px;color:green;" ></ p >
< script >
function myClick() {
// return Link crossOrigin Property
var newVar = document
.getElementById("linkid").crossOrigin;
document.getElementById("pid")
.innerHTML = newVar;
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers:
- Google Chrome
- Mozilla Firefox
- Edge
- Safari
- Opera
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...