JavaScript automatically pops up window and closes window code automatically

Source: Internet
Author: User

JavaScript automatically pops up window and closes window code automatically

<HTML>

<HEAD>

<TITLE> automatically exit window </TITLE>

<SCRIPT>

<! --

Var flyingwin

Var popupwidth = 200

Var popupheight = 150

Var marginright

Var windowcenter

Var I _top = 200

Var I _left =-popupwidth-50

Var step = 40

Var timer

Var waitingtime= 5000

Var pause = 20

Function showWindow (){

Flyingwin = window. open ("", "flyingwin", "toolbar = no, width =" + popupwidth + ", height =" + popupheight + ", top = 100, left = "+ (-popupwidth) + "");

Flyingwin.doc ument. open ();

Flyingwin.doc ument. write ("

Flyingwin.doc ument. close ();

 

If (document. all ){

Marginright = screen. width + 50

}

If (document. layers ){

Marginright = screen. width + 50

}

Windowcenter = Math. floor (marginright/2)-Math. floor (popupwidth/2)

Movewindow ()

 

}

Function movewindow (){

If (I _left <= windowcenter ){

Flyingwin. moveTo (I _left, I _top)

I _left + = step

Timer = setTimeout ("movewindow ()", pause)

}

Else {

ClearTimeout (timer)

Timer = setTimeout ("movewindow2 ()", waitingtime)

}

}

Function movewindow2 (){

If (I _left <= marginright ){

Flyingwin. moveTo (I _left, I _top)

I _left + = step

Timer = setTimeout ("movewindow2 ()", pause)

}

Else {

ClearTimeout (timer)

Flyingwin. close ()

}

}

// -->

</SCRIPT>

</HEAD>

<BODY onload = showWindow ()> </BODY>

</HTML> </td>

</Tr>

</Table>

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.