if((document.getElementById("avatarZica").innerHTML == "")){
document.getElementById("avatarLegal").addEventListener("click", function(){
document.getElementById("avatarZica").innerHTML = "<canvas class='emscripten' id='canvas' oncontextmenu='event.preventDefault()' height='400px' width='250px'></canvas>";
var imported = document.createElement('script');
imported.src = 'avatar/Release/UnityLoader.js';
document.head.appendChild(imported);
console.log(document.getElementById("avatarZica").innerHTML);
});
}
Code being used inside the index.php file. I made the condition so that if it was the first time the user clicked then it would execute the code above creating the avatar to translate the page content, but if I click again it gives an error saying that the file already exists and locks the page. Apparently the code is right and the condition too, but every time I click on the object it tries to recreate the file and gives error on behalf of Unity. Thanks in advance. Home Att,