Home > Net >  Show image when i have an especific error
Show image when i have an especific error

Time:12-26

i use mikrotik hotspot, and i have an error, i like to show an image chat.git whet this appear

the code is

$(if error)<script type="text/javascript">
var error = "$(error)";
if (error == "simultaneous session limit reached") {
<img src="/chat.gif" alt="Chat Here"> 
}
else if (error == "invalid password") {
document.write("Contrasena erronea");
}
else if (error == "no valid profile found") {
document.write("Tiempo terminado, consigue otra Ficha.");
}
else if (error == "User $(username) not found") {
document.write("Mete bien el usuario.");
}
else document.write("$(error)")
</script>$(endif)

CodePudding user response:

I think you need to append the img tag to the document. like the following.

$(if error)<script type="text/javascript">
var error = "$(error)";
if (error == "simultaneous session limit reached") { 
const img = document.createElement('img');
img.setAttribute('src', '/chat.gif');
img.setAttribute('alt, 'Chat Here');
document.appendChild(img);
}
else if (error == "invalid password") {
document.write("Contrasena erronea");
}
else if (error == "no valid profile found") {
document.write("Tiempo terminado, consigue otra Ficha.");
}
else if (error == "User $(username) not found") {
document.write("Mete bien el usuario.");
}
else document.write("$(error)")
</script>$(endif)

CodePudding user response:

On the html i insert

<div id="container"></div>

and on the script

$(if error)<script type="text/javascript">
var error = "$(error)";
if (error == "simultaneous session limit reached") { 
var url = '/chat.gif';
var link = document.createElement('a');
link.href = "https://1147.3cx.cloud/callus/#apwifi";
var image = new Image();
image.src = url;
link.appendChild(image);
document.getElementById('container').appendChild(link); 
}
else if (error == "invalid password") {
document.write("Contrasena erronea");
}
else if (error == "no valid profile found") {
document.write("Tiempo terminado, consigue otra Ficha.");
}
else document.write("$(error)")
</script>$(endif)
  • Related