Skip to content
Related Articles

Related Articles

HTML DOM Audio crossOrigin Property

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 06 Apr, 2022

The HTML DOM Audio crossOrigin property is used to set or return the value of the crossorigin attribute of the <audio> 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.
audioObject.crossOrigin;
  • It is used to set the cross-origin property.
audioObject.crossorigin="anonymous | use-credentials;  

Property Values 

  • anonymous: It has a default value. It defines that 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 audio cross-origin property.   

HTML




<!DOCTYPE html>
<html>
  
<body>
    <center>
        <h1 style="color:green">GeeksforGeeks</h1>
        <h2>HTML DOM Audio crossOrigin Property</h2>
  
  
        <audio id="audio" controls crossorigin="anonymous" autoplay>
            <source id="mp4_src"
                src=
                type="audio/mp3">
  
            <source id="ogg_src" src=
                type="audio/ogg">
        </audio>
        <br>
        <button onclick="my_Geek()">
            Return crossorigin property
        </button>
        <p id="sudo"></p>
  
  
        <script>
            function my_Geek() {
                var cors = document.getElementById("audio").crossOrigin;
                document.getElementById("sudo").innerHTML = cors;
            }         
        </script>
    </center>
</body>
  
</html>

Output 

 

Supported Browsers:

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!