Exo*_*oon 6 html javascript jquery sweetalert2
当用户在我的网站上发布评论时,我正在使用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>
Run Code Online (Sandbox Code Playgroud)
小智 13
我通过简单地在fire(): heightAuto: false
Swal.fire({
heightAuto: false,
text: "I\'m sure this would run on SWAL2@7*"
)};
Run Code Online (Sandbox Code Playgroud)
小智 5
基于版本 7.* 你可以使用这种风格:
html.swal2-shown,body.swal2-shown { overflow-y: hidden !important; height: auto!important;}
Run Code Online (Sandbox Code Playgroud)
尝试这个
$('#comment').click(function(event){
//....swal stuff
event.preventDefault();
});
Run Code Online (Sandbox Code Playgroud)