Open In App

HTML DOM Link crossOrigin Property

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:



linkObject.crossOrigin;
linkObject.crossorigin="anonymous | use-credentials;

Property values: 

Example 1: Below HTML code returns the link cross-origin property. 






<!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:


Article Tags :