Skip to content
Related Articles

Related Articles

HTML DOM Image crossOrigin Property

View Discussion
Improve Article
Save Article
  • Last Updated : 20 Jun, 2022

The HTML DOM Image crossOrigin property is used to set or return the value of the crossorigin attribute of the <img> element. This attribute is used to specify the HTTP CORS request when fetching or loading the stylesheet or icon files from the third-party server.


  • It returns the cross-origin property.
  • It is used to set the cross-origin property.
imgObject.crossorigin="anonymous | use-credentials;

Property Values:  

  • anonymous: It has a default value. It defines a CORS request that will be sent without passing the credentials information.
  • use-credentials: A cross-origin request will be sent with credentials, cookies, and certificate.

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


<!DOCTYPE html>
        <h1 style="color:green;">
        <h2>DOM Image crossOrigin Property</h2>
        <img id="myImage" align="center" src=
            width="200" height="200"
            crossorigin="anonymous" />
            Click on the below button to return
            the crossorigin property
        <button onclick="btnClick()">
       <h2 id="statusID" style="color:green;"></h2>
        function btnClick() {
            var txt = document.getElementById("myImage").crossOrigin;
            document.getElementById("statusID").innerHTML = txt;



Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!