A window crossing the screen
An even more original effect than an image crossing a page is a window crossing the browser. This can be useful for displaying
a warning before the user visits the site.
Include this script in the head of your page:
<script>
<!-- Beginning of JavaScript -
var popwindow
var popwindowwidth=480
var popwindowheight=80
var popwindowtop=20
var popwindowURL="popupcontent.htm"
var waitingtime=4
var pause=20
var step=40
var popwindowleft=-popwindowwidth-50
var marginright
var pagecenter
var timer
waitingtime= waitingtime*1000
function showWindow() {
popwindow = window.open(popwindowURL, "popwindow", "toolbar=no,width="+popwindowwidth+
",height="+popwindowheight+",top="+popwindowtop+",left="+(-popwindowwidth)+"");
if (document.all) {
marginright = screen.width+50
}
if (document.layers) {
marginright = screen.width+50
}
pagecenter=Math.floor(marginright/2)-Math.floor(popwindowwidth/2)
movewindow()
}
function movewindow() {
if (popwindowleft<=pagecenter) {
popwindow.moveTo(popwindowleft,popwindowtop)
popwindowleft+=step
timer= setTimeout("movewindow()",pause)
}
else {
clearTimeout(timer)
timer= setTimeout("movewindow2()",waitingtime)
}
}
function movewindow2() {
if (popwindowleft<=marginright) {
popwindow.moveTo(popwindowleft,popwindowtop)
popwindowleft+=step
timer= setTimeout("movewindow2()",pause)
}
else {
clearTimeout(timer)
popwindow.close()
}
}
// -->
</script>
Customise this script with the following arguments:
- Specify the width and height of the crossing window in pixels(popwindowwidth=480 and popwindowheight=80)

- Define the window height relative to the parent window (popwindowtop=20). In our example, the crossing window will be positioned 20 pixels lower than the parent window top.

- Specify the file to be displayed in the crossing window (popwindowURL="popupcontent.htm")

- Choose the delay in seconds during which the window will stay fixed in the middle of the screen (waitingtime=4)

- Set the window scrolling speed by specifying the distance crossed at each step (step=40) and the delay between two steps (pause=20)

Don't forget to activate this script in the <Body> tag of your page:
<body onLoad="showWindow()">
Discover all Webmaster scripts.