单击“确定”后如何停止 sweetalert 滚动到顶部?

2024-03-23

我在用着甜蜜警报2 https://sweetalert2.github.io当用户在我的网站上发表评论时的脚本,它会向下滚动到他们的评论并弹出甜蜜警报,但是当他们在甜蜜警报框中单击“确定”时,它会滚动回顶部。

从我读到的内容来看,我需要某种预防默认之类的东西,但我不知道它会去哪里?

这是我的脚本:

<!-- Sweet alert -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.6.8/sweetalert2.min.js"></script>
<script>
window.location.hash = "comment-<?php echo $newcommentid; ?>";
 $(document).ready(function () {
    swal({
                title: "Comment Posted",
                text: "Thanks, your comment has now been successfully posted.",
                type: "success"
            });
 });     

</script>

我通过简单地在fire(): heightAuto: false

Swal.fire({
  heightAuto: false,
  text: "I\'m sure this would run on SWAL2@7*"
)};
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

单击“确定”后如何停止 sweetalert 滚动到顶部? 的相关文章

随机推荐