作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 JavaScript 新手。我的要求是,如果我从服务器端获取列表作为空列表,则不显示弹出窗口。在此要求之前,我正在执行类似下面的代码,只要用户点击 URL,就会弹出窗口,因为我使用了 window.onload 。现在要求发生了变化,我需要仅在后端有一些数据时才显示弹出窗口。请帮我解决这个问题。
<script>
window.onload = function () {
$('#homePopup').bPopup({
easing: 'easeOutBack', //uses jQuery easing plugin
speed: 550,
transition: 'slideDown'
})
}
</script>
<div id="homePopup"><span class="buttonCloseModal b-close"><span>X</span></span>
<h1>Notifications</h1>
<div class="ListContainerScroll">
<div>
<asp:Repeater ID="rptrNotification" runat="server" OnItemDataBound="rptrNotification_ItemDataBound">
<ItemTemplate>
<div>
<asp:Literal ID="litNotificationTitle" runat="server" Text='<%# Bind("Title") %>'></asp:Literal>
</div>
<div>
<asp:Literal ID="litNotificationDesc" runat="server" Text='<%# ((SPListItem)Container.DataItem)["NotificationDescription"] %>'></asp:Literal>
</div>
</ItemTemplate>
</asp:Repeater>
<div class="noDataAvailable" runat="server" id="divNoDataAvailable" visible="false"></div>
</div>
</div>
</div>
我正在 .ascx 中执行此代码
最佳答案
您在窗口的 onload
事件函数中放入的一段代码,您将在 ajax 成功回调中放入该代码(我猜您正在使用 jQuery ajax 请求数据)
$.ajax({
url: 'http://myawesomeurl.net',
success: function (ajaxResponse) {
//your code start
$('#homePopup').bPopup({
easing: 'easeOutBack', //uses jQuery easing plugin
speed: 550,
transition: 'slideDown'
})
);
//your code end
}
});
关于javascript - 如何在 JavaScript 中禁用弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26204920/
我是一名优秀的程序员,十分优秀!