Copy codeThe Code is as follows:
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> code for preventing the appearance of PS with JavaScript-www.jb51.net </title>
</Head>
<Body onload = setValues ()>
<Center>
<SCRIPT language = JavaScript>
<! -- Beginning of JavaScript-
Var x, y
Var marginbottom
Var marginleft = 0
Var margintop = 0
Var marginright
Var cliptop
Var clipbottom
Var clipleft
Var clipright
Var clippoints
Var ballheight = 150
Var ball width = 150
Var imageheight = 525
Var imagewidth = 457
Var tempo = 25
Var stepx = 12
Var stepy = 6
Var timer
Function setValues (){
If (document. all ){
Marginbottom = imageheight-ballheight
Marginright = imagewidth-ballwidth
Document. all. ball. style. posLeft = randommaker (400)
Document. all. ball. style. posTop = 0
Document. all. textcontent. style. posLeft = 0
Document. all. textcontent. style. posTop = 0
Document. all. ball. style. filter = "alpha (opacity = 0, finishopacity = 100, style = 2, startX = 0px, startY = 0px, finishX = 100px, finishY = 100px )"
Moveball ()
}
}
// Randomfunction
Function randommaker (range ){
Rand = Math. floor (range * Math. random ())
Return rand
}
Function moveball (){
Checkposition ()
If (document. all ){
Document. all. ball. style. posLeft + = stepx
Document. all. ball. style. posTop + = stepy
Cliptop = document. all. ball. style. posTop
Clipbottom = cliptop + ballheight
Clipleft = document. all. ball. style. posLeft
Clipright = clipleft + ballwidth
Clippoints = "rect (" + cliptop + "" + clipright + "" + clipbottom + "" + clipleft + ")"
Document. all. textcontent. style. clip = clippoints
Timer = setTimeout ("moveball ()", tempo)
}
}
Function checkposition (){
If (document. all ){
If (document. all. ball. style. posLeft> = marginright ){
Stepx = stepx *-1
Document. all. ball. style. posLeft-= 10
}
If (document. all. ball. style. posLeft <= marginleft ){
Stepx = stepx *-1
Document. all. ball. style. posLeft + = 10
}
If (document. all. ball. style. posTop> = marginbottom ){
Stepy = stepy *-1
Document. all. ball. style. posTop-= 10
}
If (document. all. ball. style. posTop <= margintop ){
Stepy = stepy *-1
Document. all. ball. style. posTop + = 10
}
}
}
//-End of JavaScript--->
</SCRIPT>
<Span id = textcontent style = "LEFT:-5000px; POSITION: absolute; TOP:-2000px"> </span>
<Span id = ball style = "BACKGROUND-COLOR: white; HEIGHT: 150px; POSITION: absolute; TOP:-50px; WIDTH: 150px"> </span>
</Center>
</Body>
</Html>