實(shí)用的JS代碼片段——網(wǎng)頁特效代碼很多了,這里收集整理的是一些常規(guī)的比較實(shí)用的JS代碼片斷。
字號縮放
讓文字大點(diǎn),讓更多的用戶看的更清楚。(也可以把字體變?yōu)榘俜直葋韺?shí)現(xiàn))
<script type="text/javascript"> function doZoom(size) {document.getElementById('zoom').style.fontSize=size+'px';} </script> <span id="zoom">需要指定大小的文字</span> 西安玖佰網(wǎng)絡(luò)http://www.ksblcw.cn/<a href="javascript:doZoom(16)">大</a> <a href="javascript:doZoom(14)">中</a> <a href="javascript:doZoom(12)">小</a>
跳轉(zhuǎn)菜單新窗口
<select name="select" onchange="window.open(this.options[this.selectedIndex].value)"> <option value="http://www.microsoft.com/ie"> Internet Explorer</option> <option value="http://www.microsoft.com"> Microsoft Home</option> <option value="http://msdn.microsoft.com"> Developer Network</option> </select>
添加到收藏夾和設(shè)為首頁
添加到收藏夾
<a href="javascript:window.external.addFavorite('http://鏈接','說明');">添加到收藏夾</a>
設(shè)為首頁
<a href=# onclick=this.style.behavior='url(#default#homepage)';this.setHomePage ('http://鏈接');>設(shè)為首頁</a>
打開窗口即最大化
加入背景音樂
<bgsound src="mid/windblue[1].mid" loop="-1"> 只適用于IE <embed src="music.mid" autostart="true" loop="true" hidden="true"> 對Netscape ,IE 都適用
防止點(diǎn)擊空鏈接時,頁面往往重置到頁首端
代碼“javascript:void(null)”代替原來的“#”標(biāo)記,也可以用“#nogo”來代替啊?
自動換行
style="table-layout: fixed;WORD-BREAK: break-all; WORD-WRAP: break-word"
只對IE有用...FF的話用overflow:hidden來解決,不至于影響美觀
|