Home >Web Front-end >JS Tutorial >Message prompt box effect code based on JQuery_jquery

Message prompt box effect code based on JQuery_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 18:04:251101browse

Please download the attachment for details
Take a look at the effect first:

成功提示错误提示警告信息

The contents are all collected into a 1.58KB js file
Copy code The code is as follows:

var returnurl = '';
var messagebox_timer;
$.fn.messagebox = function (message, url, type, delay) {
clearTimeout(messagebox_timer);
$("#msgprint").remove();
var m_body = $(this) ;
delay = (typeof delay == "undefined" ? 5000 : delay);
returnurl = url;
var box_style = 'position:absolute;display:none;z-index:1000;padding: 10px 30px 10px 40px;';
switch (type) {
case 1: box_style = 'border:1px solid Green;color:#090;background:url(../Icons/ok.png) 10px 10px no-repeat #F1FEF2;'; break;
case 0: box_style = 'border:1px solid Red;color:#EE1010;background:url(../Icons/error.png) 10px 10px no-repeat #FDF8E8 ;'; break;
default: box_style = 'border:1px solid Orange;color:Orange;background:url(../Icons/warning.png) 10px 10px no-repeat #FEFDE9;'; break
}
var str = "
" message "
"; m_body.append(str);
var dom_obj = document. getElementById("msgprint");
var ext_width = $("#msgprint").width();
dom_obj.style.top = (document.documentElement.scrollTop (document.documentElement.clientHeight - dom_obj.offsetHeight - $("#msgprint").height()) / 2) "px";
dom_obj.style.left = (document.documentElement.scrollLeft (document.documentElement.clientWidth - dom_obj.offsetWidth - $("# msgprint").width()) / 2) "px";
$("#msgprint").fadeIn(1000, function () { messagebox_timer = setTimeout(messagebox_out, delay) });
};
function messagebox_out() {
if (returnurl == undefined || returnurl == '') { $("#msgprint").fadeOut(1000) }
if (returnurl == "back" ) { this.history.back(-1) } else if (returnurl != "" && returnurl != undefined) { this.location.href = returnurl }
}

referenced js file:
Copy code The code is as follows:




Page code:
Copy code The code is as follows :
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn