You could create a pseudo-alert.
You can make it a modal if it is closed by a programmed event (instead of screen-triggered).
HERE is a fiddle. (click on two colors to open and close alert.
HTML
<div class='testdiv'></div>
<div class='testdiv3'></div>
<div id='dialogtest' class='testdiv2'>Alert!</div>
CSS
.testdiv {
width: 100px;
height: 100px;
margin: 0px auto;
background-color: red;
}
.testdiv3 {
width: 100px;
height: 100px;
margin: 0px auto;
background-color: green;
}
.testdiv2 {
background-color: green;
width: 50px;
height: 50px;
font-size: 15px;
}
.ui-dialog-titlebar {
display: none;
}
JS
$( ".testdiv2" ).dialog({
autoOpen: false,
modal: false,
height: 50,
width: 'auto',
position: { my: "right middle",
at: "left middle",
of : ".testdiv" }
});
$('.testdiv').click(function(){
$('.testdiv2').dialog('open');
});
$('.testdiv3').click(function(){
$('.testdiv2').dialog('close');
});
alertdialogs are blocking. Even if it was possible to create such an event, you could not trigger it because no code can be executed while the dialog is shown.KeyboardEvent + MouseEventboth at the same time? Or Another Option is we can Loose Focus of Opening in New Tab and Set Focus of Current Tab. e.g.window.focus();andwindow.blur();