Preparation of MSN message prompting class pure js
Cross-framework
No Image
Support for speed adjustment
Pop-up at any location
Ie5.5 or above
<HTML> <HEAD> <SCRIPT language = JavaScript> <! --/** // *** ========================================== ========================================================== ========================================== ** Class Name: CLASS_MSN_MESSAGE ** function: provides an example similar to the MSN message box **: using var MSG = new CLASS_MSN_MESSAGE ("aa", 200,120, "Short Message prompt :", "You have one message", "invite me to dinner today"); MSG. show ();------------------------------------------------------ ------------------------------------------- ** Author: ttyp ** mail: ttyp@21cn.com ** Date: ======================================================= ========================================================== =====================================** // ** message structure */function CLASS_MSN_MESSAGE (id, width, height, caption, title, message, target, action) {this. id = id; this. title = title; this. caption = caption; this. message = message; this.tar get = target; t His. action = action; this. width = width? Width: 200; this. height = height? Height: 120; this. time out = 150; this. speed = 20; this. step = 1; this. right = screen. width-1; this. bottom = screen. height; this. left = this. right-this. width; this. top = this. bottom-this. height; this. timer = 0; this. pause = false; this. close = false; this. autoHide = true;}/** // ** hide the message method */CLASS_MSN_MESSAGE.prototype.hide = function () {if (this. onunload () {var offset = this. height> this. bottom- This. top? This. height: this. the bottom-this.top; var me = this; if (this. timer> 0) {window. clearInterval (me. timer);} var fun = function () {if (me. pause = false | me. close) {var x = me. left; var y = 0; var width = me. width; var height = 0; if (me. offset> 0) {height = me. offset;} y = me. bottom-height; if (y> = me. bottom) {window. clearInterval (me. timer); me. pop. hide ();} else {me. offset = me. offset-me. step;} me. pop. sh Ow (x, y, width, height) ;}} this. timer = window. setInterval (fun, this. speed)}/** // ** message unload event. You can override */CLASS_MSN_MESSAGE.prototype.onunload = function () {return true;}/** // ** message command event, to implement your own connection, rewrite it **/CLASS_MSN_MESSAGE.prototype.oncommand = function () {this. close = true; this. hide ();}/** // ** Message Display Method */CLASS_MSN_MESSAGE.prototype.show = function () {var oPopup = window. createPopup (); // IE5.5 + This. pop = oPopup; var w = this. width; var h = this. height; var str = "" str + = "<TABLE style = 'border-TOP: # ffffff 1px solid; BORDER-LEFT: # ffffff 1px solid 'cellspacing = 0 cellPadding = 0 width = '000000' bgColor = # cfdef4 border = 0> "str + =" <TR> "str ++ =" <TD style = 'font-SIZE: 12px; COLOR: # 0f2c8c 'width = 30 height = 24> </TD> "str + =" <TD style = 'padding-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: # 1f336b; PADDING-TOP: 4px 'valign = center width = '000000'> "+ this. caption + "</TD>" str + = "<TD style = 'padding-RIGHT: 2px; PADDING-TOP: 2px 'valign = center align = right width = 19> "str + =" <SPAN title = close style = 'font-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: red; MARGIN-RIGHT: 4px 'id = 'btsysclose'> × </SPAN> </TD> "str + =" </TR> "str + =" <TR> "str + =" <TD style = 'padding-RIGHT: 1px; PADDING-BOTTOM: 1px 'colspan = 3 height = "+ (h-28) +"> "str + =" "+ this. title + "" str + = "" + this. message + "" str + = "" str + = "</TD>" str + = "</TR>" str + = "</TABLE>" str + =" "oPopup.doc ument. body. innerHTML = str; this. offset = 0; var me = this; oPopup.doc ument. body. onmouseover = function () {me. pause = true;} oPopup.doc ument. body. onmouseout = function () {me. pause = false;} var fun = function () {var x = me. left; v Ar y = 0; var width = me. width; var height = me. height; if (me. offset> me. height) {height = me. height;} else {height = me. offset;} y = me. bottom-me. offset; if (y <= me. top) {me. timeout --; if (me. timeout = 0) {window. clearInterval (me. timer); if (me. autoHide) {me. hide () ;}} else {me. offset = me. offset + me. step;} me. pop. show (x, y, width, height);} this. timer = window. setInterval (fun, this. speed) var BtClose = oPopup.doc ument. getElementById ("btSysClose"); btClose. onclick = function () {me. close = true; me. hide ();} var btCommand = oPopup.doc ument. getElementById ("btCommand"); btCommand. onclick = function () {me. oncommand () ;}/ ** // *** speed setting method **/CLASS_MSN_MESSAGE.prototype.speed = function (s) {var t = 20; try {t = praseInt (s);} catch (e) {} this. speed = t;}/** // *** step setting method **/CLASS_MSN_MESS AGE. prototype. step = function (s) {var t = 1; try {t = praseInt (s);} catch (e) {} this. step = t;} CLASS_MSN_MESSAGE.prototype.rect = function (left, right, top, bottom) {try {this. left = left! = Null? Left: this. right-this.width; this. right = right! = Null? Right: this. left + this. width; this. bottom = bottom! = Null? (Bottom> screen. height? Screen. height: bottom): screen. height; this. top = top! = Null? Top: this. bottom-this. height;} catch (e) {}} var MSG1 = new CLASS_MSN_MESSAGE ("aa", 200,120, "Short Message prompt:", "you have 1 message ", "invite me to dinner today"); MSG1.rect (null, screen. height-50); MSG1.speed = 10; MSG1.step = 5; // alert (MSG1.top); MSG1.show (); // two flashes at the same time and can only be replaced by layers, however, the layer does not span the framework // var MSG2 = new CLASS_MSN_MESSAGE ("aa", 200,120, "Short Message prompt:", "you have 2 messages", "OK "); // MSG2.rect (100, null, null, screen. height); // MSG2.show (); // --> SCRIPT <META content = "MSHTML 6.00.2800.1106" name = GENERATOR> </HEAD> <BODY> </HTML>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]