Javascript 一段时间后关闭引导模式
我有一个旋转成圆形的gif图像。我把它放在引导模式中。这是我的进度条。我想模态出现大约5秒钟,然后它会自动关闭。这是我的密码:Javascript 一段时间后关闭引导模式,javascript,bootstrap-modal,Javascript,Bootstrap Modal,我有一个旋转成圆形的gif图像。我把它放在引导模式中。这是我的进度条。我想模态出现大约5秒钟,然后它会自动关闭。这是我的密码: <?php function progressBar($total){ sleep($total); return "modal"; } ?> <!-- Modal ProgressBar --> <div class="modal fade" id="progressBarCenter" tabindex="-1" rol
<?php
function progressBar($total){
sleep($total);
return "modal";
}
?>
<!-- Modal ProgressBar -->
<div class="modal fade" id="progressBarCenter" tabindex="-1" role="dialog" aria-labelledby="progressBarCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="progressBarLongTitle">Your Script Is Executing...</h5>
<button type="button" class="close" data-dismiss=<?php progressBar(5); ?> aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<img src="webapps/images/progressBar.gif">
</div>
</div>
</div>
</div>
您的脚本正在执行。。。
您可以使用以下脚本在5000毫秒后关闭引导模式:
<script>
$(document).ready(function () {
$("#buttonID").click(function(){
setTimeout(function() {
$('#progressBarCenter').modal('toggle');
}, 5000);
});
});
</script>
$(文档).ready(函数(){
$(“#按钮ID”)。单击(函数(){
setTimeout(函数(){
$(“#progressBarCenter”).modal('toggle');
}, 5000);
});
});
您可以使用以下脚本在5000毫秒后关闭引导模式:
<script>
$(document).ready(function () {
$("#buttonID").click(function(){
setTimeout(function() {
$('#progressBarCenter').modal('toggle');
}, 5000);
});
});
</script>
$(文档).ready(函数(){
$(“#按钮ID”)。单击(函数(){
setTimeout(函数(){
$(“#progressBarCenter”).modal('toggle');
}, 5000);
});
});
您编写的PHP将无法工作
尝试使用Javascript click()函数作为按钮和已使用的sleep()函数:
$(document).ready(function(){
$('button#ajaxSubmit').click(function(e){
setTimeout($total);
$('#progressBarCenter').modal('toggle');
});
});
此JS的第一行将等待整个页面加载,然后再让代码运行。第二行将在用户单击表单按钮后运行sleep(),然后切换模式
并将id
添加到您的
,如下所示:
<button type="button" class="close" aria-label="Close" id="ajaxSubmit">
您编写的PHP将无法工作
尝试使用Javascript click()函数作为按钮和已使用的sleep()函数:
$(document).ready(function(){
$('button#ajaxSubmit').click(function(e){
setTimeout($total);
$('#progressBarCenter').modal('toggle');
});
});
此JS的第一行将等待整个页面加载,然后再让代码运行。第二行将在用户单击表单按钮后运行sleep(),然后切换模式
并将id
添加到您的
,如下所示:
<button type="button" class="close" aria-label="Close" id="ajaxSubmit">
我在IE中做了一个调试器,并意识到不能在javascript中使用睡眠函数,因为它不存在。您需要改用setTimeout()函数。谢谢@Chukwuemeka Inya我在IE中做了一个调试器,并意识到不能在javascript中使用睡眠函数,因为它不存在。您需要改用setTimeout()函数。谢谢@Chukwuemeka Inya您不能使用服务器端脚本(PHP)来完成这项工作,您需要JavaScript,一种客户端脚本语言。请参阅JavaScript的setTimeout()
。您不能使用服务器端脚本(PHP),您需要JavaScript,一种客户端脚本语言。请参阅JavaScript的setTimeout()
。我尝试了您建议的代码,但无效。我意识到javascript函数从未被调用,因为我将这行代码放入函数中。document.write('在脚本标记后打印此文件');但从来没有人打过电话。我还将代码包装在一个标记中。我做错了什么?我尝试了你建议的代码,但不起作用。我意识到javascript函数从未被调用,因为我将这行代码放入函数中。document.write('在脚本标记后打印此文件');但从来没有人打过电话。我还将代码包装在一个标记中。我做错了什么?