[JavaScript] announcement Div implementation

Source: Internet
Author: User

The announcement window may be blocked by some netassistant if it is used as a pop-up window! So I wrote an announcement Div's Js.

Demo address: http://blog.csdn.net/bgu/

CodeAs follows: (put it in the body area)

< Div ID = " Affiche " Ondblclick = " Closediv (); " Style = " Border-Right: Black 1px outset; border-top: Black 1px outset; border-left: Black 1px outset; width: 30%; clip: rect (Auto auto ); border-bottom: Black 1px outset; position: absolute; Height: 30%; Background-color: whitesmoke; text-align: center; " Align = " Center " >

< Table height = " 100% " Width = " 100% " >

< Tr >

< TD valign = " Middle " Align = " Center " Height = " 100% " >

Here is the announcement content

< Div ID = " Timeout " > </ Div >

</ TD >

</ Tr >

</ Table >

</ Div >

< Script Language = " Javascript " >



VaR Intout = 10 ;

Timediv ();



Function Closediv ()

{

Document. getelementbyid ( " Affiche " ). Style. Display =   " None " ;

}



Function Timediv ()

{

-- Intout;

If (Random UT > 1 )

{

Window. setTimeout ( " Timediv () " , 1000 );

Document. getelementbyid ( " Timeout " ). Innertext = Intout +   " Seconds later/double-click window to automatically close! " ;

}

Else

{

Closediv ();

}

}



VaR Objdiv = Document. getelementbyid ( " Affiche " );

Setdiv ();



Function Setdiv ()

{

Objdiv. style. Top = (Document. Body. offsetheight - Objdiv. offsetheight) / 2   + Document. Body. scrolltop;

Objdiv. style. Left = (Document. Body. offsetwidth - Objdiv. offsetwidth) / 2 ;

If(Random UT>1)

{

Window. setTimeout ( " Setdiv () " , 2 00 );

}

}



</ Script >
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.