【发布时间】:2017-09-09 20:59:42
【问题描述】:
我正在使用sweetalert2 脚本,当用户在我的网站上发表评论时,它会向下滚动到他们的评论并弹出甜蜜警报,但是当他们在甜蜜警报框上单击确定时,它会滚动回顶部。
根据我一直在阅读的内容,我需要某种 preventdefault 或其他东西,但我无法弄清楚它会去哪里?
这是我的脚本:
<!-- 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>
【问题讨论】:
-
此问题已修复,请将您的 SweetAlert2 依赖项升级到最新版本。
标签: javascript jquery html sweetalert2