1
function customAlert(customMessage)
{
var interface = window.document.createElement("div");
var button = window.document.createElement("button");
var paragraph = window.document.createElement("p");
var body = window.document.body;
interface.style.width = "300px";
interface.style.height = "200px";
interface.style.backgroundColor = "rgb(80, 80, 80)";
interface.style.position = "absolute";
interface.style.left = "50%";
interface.style.transform = "translateX(-50%)";
interface.style.borderRadius = "10px";
interface.style.overflowX = "scroll";
button.textContent = "X";
button.style.border = "none";
button.style.backgroundColor = "rgb(255, 0, 0)";
button.style.color = "rgb(255, 255, 255)";
button.style.width = "30px";
button.style.height = "30px";
button.style.float = "right";
button.style.cursor = "pointer";
button.style.borderRadius = "0 10px 0 0";
button.style.outline = "none";
paragraph.style.fontFamily = "arial";
paragraph.style.color = "rgb(255, 255, 255)";
paragraph.style.position = "absolute";
paragraph.style.left = "53%";
paragraph.style.top = "40%";
paragraph.style.transform = "translateX(-53%) translateY(-40%)";
paragraph.style.fontSize = "14px";
if (customMessage == "") {
paragraph.textContent = "Está mensagem não diz nada!";
} else {
paragraph.textContent = customMessage;
}
button.addEventListener("mouseenter", function()
{
button.style.backgroundColor = "rgb(255, 90, 90)";
});
button.addEventListener("mouseout", function()
{
button.style.backgroundColor = "rgb(255, 0, 0)";
});
button.addEventListener("click", function()
{
body.removeChild(interface);
});
interface.appendChild(button);
interface.appendChild(paragraph);
body.appendChild(interface);
}
customAlert();
First of all, yes I did all this with Javascript and the file is external. But what happens to the button
it does not stand perfectly right when the text within the parameter customMessage
starts increasing. If you run customAlert("E alguma coisa!");
in the console
they see that it works perfectly, but if it’s something like customAlert("sdededededededededededededededede");
the button
starts rolling along with the text and is no longer right. I have tested almost everything and it does not remain right who can help thank.
Man, that’s just what I wanted, thanks anyway!
– Leandro Nascimento