【发布时间】:2018-06-06 17:25:41
【问题描述】:
如果会话存在,我想显示一个模式,我试过这样但它没有显示
<?php if(isset($_SESSION['Message1'])) { ?>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria- labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Welcome...</h4>
</div>
<div class="modal-body">
This is test
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(window).load(function(){
$('#myModal').modal('show');
});
</script>
<?php } ?>
提前感谢
【问题讨论】:
-
你看到了什么?控制台输出什么?是否包含引导脚本和 css?
-
请定义“它不起作用”。
-
if(!empty($_SESSION['Message1'])) 使用 this 而不是 isset()。
-
仍然没有显示模态
-
一旦删除会话条件并检查它是否显示。可能还有其他问题然后会话。还要检查是否在 html 中加载了模态。
标签: javascript php html bootstrap-modal