js特效javascript 按時消失的連結

來源:互聯網
上載者:User
提示:您可以先修改部分代碼再運行

<html><head><title>js 按時消失的連結</title><script language="javascript"><!--表示顯示的資訊-->var message='<b>按時消失的連結(5秒後自動消失)</b>'<!--定義背景色-->var backgroundcolor="#00FFFF"<!--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=0function 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('<span id="topmsg" >'+message+'</span>')<!--顯示連結的內容-->}Ypos = window.document.body.clientHeight - 60;Xpos = window.document.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='hidden'",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()topmsg.document.write(message)<!--輸出連結-->topmsg.document.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><!--本常式實現了按時消失的連結--><!--延時函數的使用方法--><!--連結的使用--><!--控制連結的背景顏色-->
提示:您可以先修改部分代碼再運行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.