I don't understand why my execCommand has been striked out or cancelled:

This is my code:
var $temp = $("<input>");
var $url = $(location).attr('href');
$('.play_all').on('click', function() {
$("body").append($temp);
$temp.val($url).select();
document.execCommand("copy");
$temp.remove();
$("copyUrl").text("URL copied!");
});
<center>
<button class="clipboard">Click me to copy current Url</button>
<p>Have you already clicked?</p>
</center>
`
I'm writing a code to copy my current url on a button click, in html and JavaScript, but my execCommand is always striked out by the code editor and I don't understand why.
Because of this the copy function doesn't work.
most likely because execCommand is deprecated and shouldn't be used anymore.
if you want to copy the value to clipboard you should use the clipboard api which requires a secure context though:
Clipboard API