0

1.So I want to change controlist="nodownload" to controlist="download" after the page loads using Javascript.

<html>
   <body>
      <audio id="preview"controls=" " controlist="nodownload" 
      <source src="horse.mp3" type="audio/ogg">
      </audio>
   </body>
</html>

2.my javascript:

window.onload = function() {
  var x = document.getElementsByid("preview"); 
  x.setAttribute("controlist", "download");
}

this doesn't work so can you rectify my errors to make it work. [Violation] 'load' handler took 23639ms [Violation] 'setTimeout' handler took 73ms [Violation] 'visibilitychange' handler took 762ms

1 Answers1

0

change that:

window.onload = function() {
  var x = document.getElementsByid("preview"); 
  x.setAttribute("controlslist", "download");
}

to:

window.onload = function() {
  var x = document.getElementsByid("preview"); 
  x.setAttribute("controlist", "download");
}

You wrong to write x.setAttribute("controlist", "download");

example:

window.onload = function() {
  var x = document.getElementById("preview"); 
  x.setAttribute("controlist", "download");
}
<html>
   <body>
      <audio id="preview"controls=" " controlist="nodownload" 
      <source src="horse.mp3" type="audio/ogg">
      </audio>
   </body>
</html>
Simone Rossaini
  • 8,115
  • 1
  • 13
  • 34
  • ` [Violation] 'load' handler took 23639ms` `[Violation] 'setTimeout' handler took 73ms` `[Violation] 'visibilitychange' handler took 762ms` – elliotalderson May 12 '20 at 07:59
  • your js but dosen't show three vertical dots which allows download option.but it works but dosen't change from no download to download – elliotalderson May 12 '20 at 08:02
  • [here](https://stackoverflow.com/questions/41218507/violation-long-running-javascript-task-took-xx-ms) for violation and you ask how to change controlist value and now js work. – Simone Rossaini May 12 '20 at 08:05