How to put this Alert JS to appear when entering the page

Asked

Viewed 520 times

0

Guys, I found this Alert custom on a website, and I’m willing to put it on my page, to enter the page, to appear the Alert.

I could not follow the instruction of the site, because in their example is to appear at the click of a button, and I do not understand anything Javascript.

I want to use the second example:

swal("Here's the title!", "...and here's the text!");

Could someone make a template as an answer for me put on my page, thank you!

3 answers

2


One way to do this is to add this library to the HTML and use it globally.

Behold:

swal("Meu alerta", "Olá alerta :D !");
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

I followed the guide instructions.

  • I did it and it’s not working, I think there’s something wrong with my html kkk, or the order I’m putting the items, putting everything inside the head

  • Like this your HTML?

  • put there at the end, after the footer the javascript code and it worked kkk. Thanks men,when I was putting in the head it did not work.

1

0

How do you add an alert when you reset the numbers?

<button id="bcen" onclick="this.textContent --;" value="10000">10000</button>
<script>
document.getElementById("bcen").style.align = "center"; // Center
document.getElementById("bcen").style.width =
"300px"; //Size
document.getElementById("bcen").style.align = "center"; // Center
document.getElementById("bcen").style.height =
"200px"; //Size
</script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.