Js special effect javascript disappears on time

Source: Internet
Author: User
Tip: you can modify some code before running

<html><head><title>Link for js to disappear on time</title><script language="javascript"><!--表示显示的信息-->Var message ='<b>Link that disappears on time (automatically disappears in 5 seconds)</b>'<!--定义背景色-->Var backgroundcolor = "#00 FFFF"<!--0 代表信息永远显示,1 代表信息只显示一段时间,2为随机显示模式-->Var displaymode = 1<!--如果显示模式为在指定时间内显示,输入时间段(1000为1秒)-->Var displayduration = 5000<!--1代表闪烁,0代表不闪烁;-->Var flashmode = 1<!--如果设置了闪烁,输入闪烁的颜色-->Var flashtocolor = "# FFFF00" function regenerate () {window. location. reload ()<!--重新载入窗口-->} Var which = 0 function regenerate2 () {if (document. layers)<!--如果是netscape浏览器,则延时700ms-->SetTimeout ("window. onresize = regenerate", 700)} function display2 () {if (document. layers ){<!--如果是netscape浏览器-->If (topmsg. visibility = "show ")<!--如果信息是可见的则改为隐藏-->Topmsg. visibility = "hide" elsetopmsg. visibility = "show"<!--否则改为可见-->} Else if (document. all ){<!--如果是ie浏览器-->If (topmsg. style. visibility = "visible") topmsg. style. visibility = "hidden"<!--如果信息是可见的改为隐藏,否则改为可见-->Elsetopmsg. style. visibility = "visible" setTimeout ("display2 ()", Math. round (Math. random () * 10000) + 10000)<!--延时一个随机时间-->} Function flash () {if (which = 0 ){<!--如果which为0-->If (document. layers)<!--netscape浏览器-->Topmsg. bgColor = flashtocolor<!--信息的背景色改为闪烁的颜色-->Elsetopmsg. style. backgroundColor = flashtocolor<!--ie时也是相同的操作-->Which = 1<!--将which置为1-->} Else {if (document. layers)<!--netscape浏览器-->Topmsg. bgColor = backgroundcolor<!--设置链接的背景颜色-->Else<!--ie浏览器-->Topmsg. style. backgroundColor = backgroundcolor<!--设置链接的背景颜色-->Which = 0<!--将which置0-->} If (document. all ){<!--ie浏览器-->Document. write (''+ message + '')<!--显示链接的内容-->} Ypos = zookeeper doc ument. body. clientHeight-60; Xpos = zookeeper doc ument. body. clientWidth-60; function logoit () {document. all. topmsg. style. left = document. body. scrollLeft + document. body. clientWidth/2<!--设置链接显示的左边界-->Document. all. topmsg. style. top = document. body. scrollTop + document. body. clientHeight<!--设置链接显示的上边界-->} Function setmessage (){<!--显示链接-->Document. all. topmsg. style. backgroundColor = backgroundcolor<!--设置链接的背景色-->Document. all. topmsg. style. visibility = "visible"<!--设置链接为可视-->If (displaymode = 1)<!--如果是模式1-->SetTimeout ("topmsg. style. visibility = 'den den '", displayduration)<!--按照设定的时间延时后,将链接的显示属性变成隐藏-->Else if (displaymode = 2)<!--如果是模式2-->Display2 ()<!--直接调用display2函数-->If (flashmode = 1) setInterval ("flash ()", 1000)<!--设置flash的延时1秒-->Window. onscroll = logoit<!--设置事件对应的函数-->Window. onresize = new Function ("window. location. reload ()")<!--重新载入窗口-->} Function setmessage2 (){<!--显示链接-->Topmsg = new Layer (window. innerWidth)<!--信件一个层,宽度固定-->Topmsg. bgColor = backgroundcolor<!--设置链接的背景色-->Regenerate2(shorttopmsg.doc ument. write (message)<!--输出链接-->Topmsg.doc ument. close () logoit2 ()<!--调用函数logoit2函数-->Topmsg. visibility = "show"<!--设置链接的显示属性-->If (displaymode = 1)<!--如果是模式 1-->SetTimeout ("topmsg. visibility = 'hide '", displayduration)<!--按照设定的时间延时后,将链接的显示属性变成隐藏-->Else if (displaymode = 2)<!--如果是模式2-->Display2 ()<!--直接调用display2函数-->If (flashmode = 1) setInterval ("flash ()", 1000)<!--设置flash的延时1秒-->} If (document. layers)<!--如果时netscape浏览器-->Window. onload = setmessage2<!--调用setmessage2函数-->Else if (document. all)<!--如果是ie浏览器-->Window. onload = setmessage<!--调用setmessage函数--></script></body></html><!--本例程实现了按时消失的链接--><!--延时函数的使用方法--><!--链接的使用--><!--控制链接的背景颜色-->
Tip: you can modify some code before running

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.