JavaScript 經典效果集_javascript技巧

來源:互聯網
上載者:User

些很實用且必用的小指令碼代碼:

指令碼1:進入首頁以後自動播放聲音 
<embed src="pnm://10.13.31.90/~kayvin/mihunji.rm" hidden=true autostart=true loop=true> 

指令碼2:進入首頁後自動最大話,省的去在自己單擊了 
<script> 
self.moveTo(0,0) 
self.resizeTo(screen.availWidth,screen.availHeight) 
</script> 

指令碼3:顯示現在時間的指令碼 
<script language=vbscript>document.write now</script> 

指令碼4:顯示最後修改時間的指令碼 
<script>document.write(document.lastModified)</script> 

指令碼5:設為首頁,加為收藏,加入頻道,啟動outlook發信 
<a style="cursor:hand" 
onclick="this.style.behavior="url(#default#homepage)"; 
this.setHomePage("yourURL">設為首頁</a> 

<a style="cursor:hand" 
onclick="window.external.AddFavorite(location.href,document.title);">加入收藏</a> 

<a href=javascript:window.external.addChannel("typhoon.cdf")>加入頻道</a> 

<a href="youEmail">與我聯絡</a> 

指令碼6:狀態列動態顯示現在時間 
<script> 
function see(){ 
window.setTimeout("see()",1000); 
today = new Date(); 
self.status = today.toString(); 
} 
</script> 
<body onload=see()> 

指令碼7:關閉視窗的指令碼 
<a href=javascript:close()>[關閉視窗]</a> 

指令碼8:按下F12鍵,直接返回首頁 
<script>function look(){ 
if(event.keyCode==123){document.location.href=http://10.13.31.90/~kayvin/} 
} 
if(document.onkeydown==null) 
{document.onkeydown=look} 
</script> 

指令碼9:後退,重新整理,前進

複製代碼 代碼如下:

<input type=button value=後退 onclick=history.go(-1)> 
<input type=button value=重新整理 onclick=history.go(-0)> 
<input type=button value=前進 onclick=history.go(+1)> 

指令碼10:設定時間快顯視窗,4000=4秒,當然你可以自訂
複製代碼 代碼如下:

<script>function l() { 
window.open("yourURL","name","width=500,height=150,border=0") 
} 
setTimeout("l()",4000) 
</script>

二 滑鼠旁邊的提示資訊,類似與163登入後的頁面提示效果
tip <script Language="JavaScript"> //***********預設設定定義.********************* tPopWait=50;//停留tWait豪秒後顯示提示。 tPopShow=5000;//顯示tShow豪秒後關閉提示 showPopStep=20; popOpacity=99; //***************內部變數定義***************** sPop=null; curShow=null; tFadeOut=null; tFadeIn=null; tFadeWaiting=null; document.write("<style type='text/css'id='defaultPopStyle'>"); document.write(".cPopText { background-color: #F8F8F5;color:#000000; border: 1px #000000 solid;font-color: font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: Alpha(Opacity=0)}"); document.write("</style>"); document.write("<div id='dypopLayer' class='cPopText'></div>"); function showPopupText(){ var o=event.srcElement; MouseX=event.x; MouseY=event.y; if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""}; if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""}; if(o.dypop!=sPop) { sPop=o.dypop; clearTimeout(curShow); clearTimeout(tFadeOut); clearTimeout(tFadeIn); clearTimeout(tFadeWaiting); if(sPop==null || sPop=="") { dypopLayer.innerHTML=""; dypopLayer.style.filter="Alpha()"; dypopLayer.filters.Alpha.opacity=0; } else { if(o.dyclass!=null) popStyle=o.dyclass else popStyle="cPopText"; curShow=setTimeout("showIt()",tPopWait); } } } function showIt(){ dypopLayer.className=popStyle; dypopLayer.innerHTML=sPop; popWidth=dypopLayer.clientWidth; popHeight=dypopLayer.clientHeight; if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24 else popLeftAdjust=0; if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24 else popTopAdjust=0; dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust; dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust; dypopLayer.style.filter="Alpha(Opacity=0)"; fadeOut(); } function fadeOut(){ if(dypopLayer.filters.Alpha.opacity<popOpacity) { dypopLayer.filters.Alpha.opacity+=showPopStep; tFadeOut=setTimeout("fadeOut()",1); } else { dypopLayer.filters.Alpha.opacity=popOpacity; tFadeWaiting=setTimeout("fadeIn()",tPopShow); } } function fadeIn(){ if(dypopLayer.filters.Alpha.opacity>0) { dypopLayer.filters.Alpha.opacity-=1; tFadeIn=setTimeout("fadeIn()",1); } } document.onmouseover=showPopupText; </script>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.