1 回答
TA贡献1900条经验 获得超5个赞
您可以使用另一个打开并覆盖整个页面的 div,下面的代码就是这样编写的。
不会打扰您的大部分代码,我添加<div>了将在页面加载时隐藏的代码。这<div>将在弹出窗口打开时显示,并<div>在对话框关闭时隐藏。
$(document).ready(function() {
jQuery(document).on("click", ".ext_link", function() {
$('#scrLoader').show();
$("<div>Thank you for visiting You are now being taken to an external site. </div>").dialog().attr('id', 'dialog-confirm').css('display', 'none');
var link_val = this;
$('#dialog-confirm').dialog({
title: "External Link",
height: "auto",
width: 410,
resizable: false,
buttons: {
"Ok": function() {
window.open(link_val.href);
$(this).dialog("close");
$(this).dialog('destroy').remove();
},
Cancel: function() {
$('#scrLoader').hide();
jQuery(this).dialog("close");
$(this).dialog('destroy').remove();
}
}
}).dialog("widget").find(".ui-dialog-titlebar").hide();
return false;
});
});
#scrLoader {
background-color: #333;
opacity: 0.8;
position: fixed;
left: 0px;
top: 0px;
z-index: 100;
height: 100%;
width: 100%;
overflow: hidden;
background-image: url('your path to a loader gif');
background-position: center;
background-repeat: no-repeat;
}
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css" />
<input type="button" class="ext_link" value="click me" />
<div id="scrLoader" style="display: none;" hidden="true"></div>
您还可以使用 GIF,例如加载程序 GIF,它会在特定 div 打开时显示,以便用户了解某些进程正在进行中。
希望这可以帮助。
添加回答
举报