如果用户单击外部链接,jQuery UI 对话框会显示“确定”和“取消”按钮,当他们点击“确定”时,它应该将它们带到外部站点。
一切都按预期工作,但问题在于modal:true;当对话框打开时,用户可以在背景上工作,我希望在弹出窗口打开时背景变灰。
$(window).on('load', function(){
$.expr[":"].external = function(a) {
var linkhn = a.hostname.split('.').reverse();
var linkHref = linkhn[1] + "." + linkhn[0];
var domainhn = window.location.hostname.split('.').reverse();
var domainHref = domainhn[1] + "." + domainhn[0];
return !a.href.match(/^mailto\:/) && !a.href.match(/^tel\:/) && linkHref !== domainHref;
};
$("a:external").addClass("ext_link");
});
$(document).ready(function(){
jQuery(document).on("click", ".ext_link", function () {
$("<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,
modal: false,
buttons: {
"Ok": function() {
window.open( link_val.href); $(this).dialog("close"); $(this).dialog('destroy').remove();
},
Cancel: function () {jQuery(this).dialog("close"); $(this).dialog('destroy').remove() ;}
}
}).dialog("widget").find(".ui-dialog-titlebar").hide();
return false;
});
});
梵蒂冈之花
相关分类