I have an inline JS code in my HTML and it is working on my local machine, but it is not working after I deploy it on the Pythonanywhere. The JS code is:
<script>
document.getElementById("copy-button").addEventListener("click", function () {
var buildingData = ('{{ project_json|escapejs }}');
navigator.clipboard.writeText(buildingData).then(function () {
alert("Model data copied to clipboard!");
})
.catch(function (err) {
console.error("Failed to copy model data: ", err);
});
});
</script>
And the error which I get in console log by clicking on button is:
TypeError: navigator.clipboard is undefined
I appreciate any help to solve this issue.