?? 3-1.htm
字號:
<html>
<head>
<title>按時消失的鏈接</title>
<script language="javascript">
<!--表示顯示的信息-->
var message='<b><a href="#" target="_blank">按時消失的鏈接(5秒后自動消失)</a></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=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"
else
topmsg.visibility="show" <!--否則改為可見-->
}
else if (document.all){ <!--如果是ie瀏覽器-->
if (topmsg.style.visibility=="visible")
topmsg.style.visibility="hidden" <!--如果信息是可見的改為隱藏,否則改為可見-->
else
topmsg.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<!--信息的背景色改為閃爍的顏色-->
else
topmsg.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" style="position:absolute;visibility:hidden">'+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>
<!--本例程實現了按時消失的鏈接-->
<!--延時函數的使用方法-->
<!--鏈接的使用-->
<!--控制鏈接的背景顏色-->
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -