我正在使用 sweetalert2当用户在我的网站上发表评论时的脚本,它向下滚动到他们的评论并弹出甜蜜警报,但当他们在甜蜜警报框上单击“确定”时,它会滚动回顶部。
根据我一直在阅读的内容,我需要某种防止默认或其他东西,但我无法弄清楚它会去哪里?
这是我的脚本:
<!-- 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*"
)};
关于javascript - 单击确定后如何停止 sweetalert 滚动到顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46135063/