由于某种原因,我的模态没有显示我已经说明了如果cookie确实存在,弹出窗口将不会显示但我在我的开发机器上清除了我的cookie并且它仍然没有显示控制台和我的错误控制台日志没有被点击我在visual studio中运行它。
<script type="text/javascript">
// Delayed Modal Display + Cookie On Click
$(document).ready(function () {
$('#myModal').on('hidden.bs.modal', function () {
// we want to trap the user closing the popup and we also set the cookie expiery here to seven days.
$.cookie('galgormgrouppopup', 'true', { expires: 604800000, path: '/' });
})
// If no cookie with our chosen name (e.g. no_thanks)...
if ($.cookie("galgormgrouppopup") == null) {
// Show the modal, with delay func.
$('#myModal').appendTo("body");
$("#myModal").appendTo("form:first");
function show_modal() {
console.log('does my modal get called');
$('#myModal').modal();
console.log('does my modal get called after');
}
// Set delay func. time in milliseconds
window.setTimeout(show_modal, 10000);
}
});
</script>
这是我的模态代码,它之前的.net更新面板之前没有任何问题,但似乎没有显示。
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content" style="text-align:left;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span style="display:none;" class="sr-only">Close</span></button>
<h2 class="modal-title" align="center">10% Off Your Frist Order!</h2>
</div>
<div class="modal-body">
<div class="clear"></div>
<div class="input-group">
<img src="/index-images/galgormgroupgraphic.png" width="100%" alt="10% Off First Order" />
<div style="float:left">
*excludes Furniture and Catering Equipment </div>
<div ></div>
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
<div style="clear:both;"></div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtEmail" placeholder="Enter Email for Discount" CssClass="emailField" runat="server"></asp:TextBox>
<br />
<asp:label runat="server" id="lblVoucher" style="font-size:16px;"></asp:label>
<asp:Label ID="lblblerror" runat="server" ForeColor="Red"></asp:Label>
<asp:button runat="server" CausesValidation = "false" class="btn btn-primary "
OnClick="btnNewGetVoucher_Click"
ID ="btnNewGetVoucher" style="background-color:#007B78;color:white;align-self:center;height:55px;width:100%" text="Get Voucher Code" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
<div class="modal-footer">
<!-- Make sure to include the 'nothanks' class on the buttons -->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
https://jsfiddle.net/t7hb37hw/
很抱歉,如果我的jsfiddle设置不正确,请使用它!