Js implements the image method with time limit and js time limit that disappears
This article provides examples of how to implement time-limit disappearance in JavaScript. Share it with you for your reference. The specific implementation method is as follows:
Copy codeThe Code is as follows: <Title> pictures that disappear within the specified time </title>
<Body>
<SCRIPT language = JavaScript>
<! -- Hide the script from old browsers --
// 1) create a 88*31 LOGO.
If (document. images)
Var staticlogo = new Image (758,100)
// 2) set the LOGO path.
Staticlogo. src = "/images/banner.gif"
// 3) The following is the link represented by the LOGO.
Var logolink = "http://wwwww.jb51.net /"
// 4) set the ALT attribute.
Var alttext = "code home"
// 5) set the following attributes to 1 or 0 (1 is unique to IE to hide the LOGO)
Var fadeappsview = 1
/* 6) finally set the LOGO display time, for example, 12 seconds. The value 0 indicates that the LOGO is always displayed.
*/
Var visibleduration = 5
Function regenerate (){
Window. location. reload ()
}
Function regenerate2 (){
If (document. layers)
SetTimeout ("window. onresize= regenerate", 400)
}
Var fadeset =''
If (fadeappsview)
Fadeset = "filter: alpha (opacity = 0 )"
If (document. all)
Document. write ('<span id = "logo" "style ="' + fadeset + '; position: absolute; top: 100; width:' + staticlogo. width + '; height:' + staticlogo. height + '"> </span> ')
Function bringlateral view (){
If (logo. filters. alpha. opacity <= 95)
Logo. filters. alpha. opacity + = 5
Else {
ClearInterval (viewit)
If (visibleduration! = 0)
SetTimeout ("logo. style. visibility = 'den den '", visibleduration * 1000)
}
}
Function createlogo (){
Staticimage = new Layer (100)
Staticimage. left =-300
Staticimage. top = 120
Staticimage.doc ument. write ('<a href = "' + logolink + '"> </a> ')
Staticimage.doc ument. close ()
Staticimage. visibility = "show"
Regenerate2 ()
Staticitns ()
}
If (document. layers)
Window. onload = createlogo;
If (document. all ){
W = 2
H = 2
Logo. style. left = w
Logo. style. top = h
}
Function logoit (){
Var w2 = document. body. scrollLeft + w
Var h2 = document. body. scrollTop + h
Logo. style. left = w2
Logo. style. top = h2
}
Function logoit2 (){
Staticimage. left = pageXOffset + 2
Staticimage. top = pageYOffset + 2
}
Function insertimage (){
Logo. innerHTML = '<a href = "' + logolink + '"> </a>'
If (fadeappsview)
Viewit = setInterval ("bring1_view ()", 100)
Else {
If (visibleduration! = 0)
SetTimeout ("logo. style. visibility = 'den den '", visibleduration * 1000)
}
}
If (document. all ){
Window. onscroll = logoit
Window. onresize = new Function ("window. location. reload ()")
Window. onload = insertimage
}
Function staticitns (){
SetInterval ("logoit2 ()", 90)
If (visibleduration! = 0)
SetTimeout ("staticimage. visibility = 'hide '", visibleduration * 1000)
}
// -->
</SCRIPT>
</Body>
</Html>
<Br>
<Br>
<Br>
<Br>
<Br>
<Br> the image disappears after 5 seconds.
<Br>
<Br>
<Br>
I hope this article will help you design javascript programs.