单击“确定"后,如何停止 Sweetalert 滚动到顶部? [英] How can i stop sweetalert scrolling to top after clicking ok?

查看:45
本文介绍了单击“确定"后,如何停止 Sweetalert 滚动到顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 sweetalert2 脚本,当用户在我的网站上发表评论时,它会向下滚动到他们的评论和甜蜜警报会弹出,但当他们在甜蜜警报框上单击确定时,它会滚动回顶部.

I'm using sweetalert2 script for when a user posts a comment on my site, It scrolls down to their comment and sweet alert pops up but when they click ok on the sweet alert box it scrolls back upto the top.

从我一直在阅读的内容来看,我需要某种预防违约或其他东西,但我不知道那会去哪里?

From what i've been reading i need some sort of preventdefault or something but i can't figure out where that would go?

这是我的脚本:

<!-- 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*"
)};

这篇关于单击“确定"后,如何停止 Sweetalert 滚动到顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆