I wrote the following code using jQuery to create a WebAlert instead of using the alert()
function from jQuery:
(function($){
$.fn.WebAlert = function(msg) {
// If WebAlert is Availble -> First Remove this-> callback = Yes -> Now Create New WebAlert
if ($('.WebAlert_Area').length) {
$(this).Remove_WebAlert(msg , 'Yes')
return false;
//If WebAlert Not Availble
} else {
$(this).Create_WebAlert(msg)
return false;
}
}
//Function For Create WebAlert
$.fn.Create_WebAlert = function(msg) {
$('body').append('<div class="WebAlert_Area"><div class="Msg_Area"></div></div>');
$('.WebAlert_Area .Text_Area').html(msg)
};
//Function For Remove WebAlert
$.fn.Remove_WebAlert = function(msg , callback) {
$('.WebAlert_Area').hide(1000 , function() {
$(this).remove();
if (callback == 'Yes') {
$(this).Create_WebAlert(msg)
}
})
};
})(jQuery);
$(document).ready(function() {
$('body').WebAlert('Welcome To My Web')
}};
But I think that it's too complex and non-standard, is that true?