Eric Santin
Eric Santin

Reputation: 3

How to make a SweetAlert appear when joining my web?

I'm using SweetAlert and it's working fine in my page with this button:

<button type="button" id="button1" onclick='swal("Message", "This is a message")'>Title</button>

But I want the message to popup when somebody enter the page without having to press a button.

What do I have to do?

Thanks

Upvotes: 0

Views: 57

Answers (2)

Monzurul Shimul
Monzurul Shimul

Reputation: 8396

Try this:

<script>
    $( document ).ready(function() {
        swal("Message", "This is a message");
    });
</script>

Upvotes: 0

Anph
Anph

Reputation: 163

<script>
  window.onload = function(){
     swal("Message", "This is a message");
 }
</script>

You can try include this to your html document! Hope this can help!

Upvotes: 1

Related Questions