1 function showmessage (MSG, bgcolor, bordercolor) {2 if ($ ("# showdiv "). length <= 0) {3 var DIV = invalid argument Doc ument. createelement ("Div"); 4 Div. innerhtml = MSG; 5 Div. id = "showdiv"; 6 Div. style. color = "black"; 7 Div. style. width = "400px"; 8 DIV. style. height = "Auto"; 9 Div. style. padding = "15px"; 10 Div. style. lineheight = "22px"; 11 Div. style. overflow = "Auto"; 12 Div. style. border = bordercolor; 13 Div. style. display = "NONE"; 14 Div. style. position = "fixed"; 15 Div. style. zindex = 40; 16 Div. style. fontfamily = "Microsoft yahei"; 17 Div. style. fontsize = "15px"; 18 19 Div. style. background = bgcolor; 20 var P = too many Doc ument. createelement ("p"); 21 p. style. marginbottom = "0px"; 22 p. style. textalign = "right"; 23 24 Response (p;.html ("<a id = 'closea' href = 'javascript: void (0) 'style = 'text-Decoration: none '> close </a> "); 25 Div. appendchild (p); 26 too many Doc ument. body. appendchild (DIV); 27 28 Div. style. left = (registry.document.doc umentelement. clientwidth/2-parseint (div. style. width, 10)/2) + "PX"; 29 Div. style. top = registry.document.doc umentelement. clientheight/2-$ (DIV ). height ()/2 + "PX"; 30 animationdiv (DIV); 31 32 // you need to bind the event after the element is loaded by the body, otherwise, the event 33 $ ("# closea") cannot be executed before loading "). click (function () {34 $ ("# showdiv "). remove (); 35}); 36 37 $ (window ). resize (function () {38 Div. style. left = (registry.document.doc umentelement. clientwidth/2-parseint (div. style. width, 10)/2) + "PX"; 39 Div. style. top = registry.document.doc umentelement. clientheight/2-$ (DIV ). height ()/2 + "PX"; 40 }); 41 42} else {43 // $ ("# showdiv" cmd.html (MSG + "<P style = 'text-align: right '> <a id = 'closea' href = 'javascript: void (0)' style = 'text-Decoration: none '> close </a> </P> "); 44 // The event is bound after the element is loaded by the body, otherwise, the event cannot be executed before loading: 45 $ ("# closea "). click (function () {46 $ ("# showdiv "). remove (); 47}); 48} 49}