加入我的网站时如何使 SweetAlert 出现?

How to make a SweetAlert appear when joining my web?

我正在使用 SweetAlert,它在我的页面中使用此按钮运行良好:

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

但我希望当有人无需按按钮即可进入页面时弹出该消息。

我需要做什么?

谢谢

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

您可以尝试将此添加到您的 html 文档中!希望对您有所帮助!

试试这个:

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