Pure JS Writing Cross-Frame No Image Support Advance Arbitrary Popup Need IE5.5 or more
<
HTML
> <
HEAD
>
<
Script logage
=
JavaScript
>
/ *
** =================================================================================================================================================================== ============================================================================================================================================================================================================= ** Class Name: Class_MSN_MESSAGE ** Function: Provide similar MSN message box ** Example: ------------------------------- -------------------------------------------------- ------------------ Var msg = new class_msn_message ("aa", 200, 120, "short message tips:", "You have 1 news", "Today, please dinner Ha "); msg.show (); -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- --------- ** author: ttyp **-mail: ttyp@21cn.com ** date: 2005-3-18 ** ================ ============================================================================================================================================================================================================= ================================= *
* /
/ *
* Message Construction
* /
FUNCTION
Class_MSN_Message (ID, Width, Height, Caption, Title, Message, Target, Action) {this
.id .id
=
Id;
THIS
.title
=
Title;
THIS
.caption
=
Caption;
THIS
.meseage
=
Message;
THIS
.target
=
Target;
THIS
.action
=
Action;
THIS
.width
=
Width
?
Width:
200
;
THIS
. Height
=
HEIGHT
?
HEIGHT:
120
;
THIS
.timeout
=
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
}
/ *
* Hide Message Method
* /
Class_MSN_Message.Prototype.hide
=
FUNCTION
() {
IF
(
THIS
.onload ()) {
VAR
Offset
=
THIS
. Height
>
THIS
.bottom
-
THIS
.top
?
THIS
.height:
THIS
.bottom
-
THIS
.top;
VAR
ME
=
THIS
;
IF
(
THIS
.timer
>
0
) {WINDOW.CLARINTERVAL (Me.Timer);
VAR
Fun
=
FUNCTION
() {
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.show (x, y, width);}
THIS
.timer
=
Window.setInterval (Fun,
THIS
.SPEED)}}}}}
/ *
* Message uninstall events can be rewritten
* /
Class_MSN_Message.Prototype.onunload
=
Function () {
Return
True
}
/ *
* Message Command Event, to implement your own connection, please renote it *
* /
Class_MSN_Message.Prototype.onCommand
=
FUNCTION
() {
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
hide
=
THIS
.height;
VAR
Str
=
"
"
Str
=
"
td>
" Str = " |
" Str = " × span> td> " Str = " TR> " Str = " | |
"
(h - Twist )
" > " Str = " "
THIS .meseage
" Font> div>" Str = " Div> " Str = " Td> " Str = " TR> " Str = " TABLE> " Str = " Div> " Opopup.Document.body.innerhtml = Str; THIS .offset = 0 ; VAR ME = THIS ; VAR Fun = FUNCTION () { VAR x = me.left; VAR 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.CLARINTERVAL (Me.Timer); me.hide ();}} Else {Me.offset = Me.offset
Me.Step;} me.pop.show (x, y, width);} THIS .timer = Window.setInterval (Fun, THIS .SPEED VAR Btclose = Opopup.document.getlementByid ( " btsysclose " Btclose.onclick = FUNCTION () {Me.hide (); VAR BTCommand = Opopup.document.getlementByid ( " BTCommand " BTcommand.onclick = FUNCTION () {Me.oncommand ();}} / * ** Setting speed method * * / Class_MSN_Message.Prototype.Speed = FUNCTION (s) { VAR t = 20 ; Try {T = PRASEINT (S); Catch (e) {} THIS .SPEED = T; / * ** Set the step size method * * / Class_MSN_Message.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 } Catch (e) {}} VAR MSG1 = New Class_MSN_MESSAGE " AA " , 200, 120 , " Short message prompt: " , " You have 1 news " , " Please ask me to eat today. " ); Msg1.rect NULL , NULL , NULL , Screen.height - 50 ); Msg1.speed = 10 ; Msg1.step = 5 ; // Alert (msg1.top); Msg1.show (); // At the same time, two flashes, only replace it, but the layer is not cross-frame // Var msg2 = new class_msn_message ("aa", 200, 120, "short message tips:", "You have 2 news", "Okay"); // Msg2.rect (100, null, null, screen.height); // Msg2.show (); // -> Script > < Meta Content = " MSHTML 6.00.2800.1106 " Name = Generator > HEAD > < Body > Body > HTML >
转载请注明原文地址:https://www.9cbs.com/read-38666.html New Post(0)
|