gpt4 book ai didi

javascript - 如何在 JavaScript 中禁用弹出窗口

转载 作者:行者123 更新时间:2023-12-03 11:42:33 24 4
gpt4 key购买 nike

我是 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com