常用的代碼集合
表格變色 <TD onmouseover="this.style.backgroundColor='#FFFFFF'" onmouseout="this.style.backgroundColor=''" style="CURSOR: hand">
禁止復(fù)制,鼠標(biāo)拖動(dòng)選取 <body ondragstart=window.event.returnValue=false oncontextmenu=window.event.returnValue=false onselectstart=event.returnValue=false>
普通iframe頁(yè)面 <iframe name="name" src="main.htm" width="450" height="287" scrolling="Auto" frameborder="0"></iframe>
iframe自適應(yīng)高度 <iframe name="pindex" src="index.asp" frameborder=false scrolling="auto" width="100%" height="100%" frameborder=no onload="document.all['pindex'].style.height=pindex.document.body.scrollHeight" ></iframe>
IE地址欄前換成自己的圖標(biāo)&可以在收藏夾中顯示出你的圖標(biāo) <link rel="Shortcut Icon" href="favicon.ico" href_cetemp="favicon.ico" href_cetemp="favicon.ico"> <link rel="Bookmark" href="favicon.ico">
字號(hào)縮放 越來(lái)越多的人長(zhǎng)時(shí)間的泡網(wǎng),眼鏡的普及率也越來(lái)越高,讓文字大點(diǎn),讓更多的用戶看的更清楚。 <script type="text/javascript"> function doZoom(size) {document.getElementById('zoom').style.fontSize=size+'px';} </script> <span id="zoom">需要指定大小的文字</span> <a href="javascript:doZoom(16)">大</a> <a href="javascript:doZoom(14)">中</a> <a href="javascript:doZoom(12)">小</a>
select擋住div的解決方法 在div里加入下面的代碼,根據(jù)需要調(diào)整就可以了。 <iframe src="javascript:false" scrolling="no" frameborder="0" style="z-index:-1;position:absolute; top:5px; left:2px;width:168;height:100px;"> </iframe>
iframe(嵌入式幀)自適應(yīng)高度 填寫的嵌入地址一定要和本頁(yè)面在同一個(gè)站點(diǎn)上,否則會(huì)提示“拒絕訪問(wèn)!”。對(duì)跨域引用有權(quán)限問(wèn)題,請(qǐng)查閱其他資料。 <iframe name="guestbook" src="gbook/index.asp" scrolling=no width="100%" height="100%" frameborder=no onload="document.all['guestbook'].style.height=guestbook.document.body.scrollHeight"></iframe>
跳轉(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>
flash透明選項(xiàng) <param name="wmode" value="transparent">
添加到收藏夾和設(shè)為首頁(yè) <a href=# onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.makewing.com/lanren/');">設(shè)為首頁(yè)</a>
<a href="javascript:window.external.AddFavorite('http://www.makewing.com/lanren/','懶人圖庫(kù)')">收藏本站</a>
記錄并顯示網(wǎng)頁(yè)的最后修改時(shí)間 <script language=JavaScript> document.write("最后更新時(shí)間: " + document.lastModified + "") </script>
節(jié)日倒計(jì)時(shí) <Script Language="JavaScript"> var timedate= new Date("October 1,2002"); var times= "國(guó)慶節(jié)"; var now = new Date(); var date = timedate.getTime() - now.getTime(); var time = Math.floor(date / (1000 * 60 * 60 * 24)); if (time >= 0) document.write( "現(xiàn)在離"+times+"還有: "+time +"天") </Script>
加在HEAD里 禁止緩存 <meta http-equiv="Expires" CONTENT="0"> <meta http-equiv="Cache-Control" CONTENT="no-cache"> <meta http-equiv="Pragma" CONTENT="no-cache">
讓IFRAME框架內(nèi)的文檔的背景透明 <iframe src="about:<body style='background:transparent'>" allowtransparency></iframe>
打開窗口即最大化 <script language="JavaScript"> <!-- Begin self.moveTo(0,0) self.resizeTo(screen.availWidth,screen.availHeight) // End --> </script>
加入背景音樂(lè) <bgsound src="mid/windblue[1].mid" loop="-1"> 只適用于IE <embed src="music.mid" autostart="true" loop="true" hidden="true"> 對(duì)Netscape ,IE 都適用
防止點(diǎn)擊空鏈接時(shí),頁(yè)面往往重置到頁(yè)首端 代碼“javascript:void(null)”代替原來(lái)的“#”標(biāo)記
文字或圖片彈出指定大小的窗口 在body中加入 <script language="JavaScript" type="text/JavaScript"> function MM_openBrWindow(theURL,winName,features) {window.open(theURL,winName,features);} </script> 彈出代碼 <a href="#" target="_self" onClick="MM_openBrWindow('windows01.htm','','width=550,height=380')" width="550" height="380" border="0">圖片或文字</a>
flash按鈕加鏈接 on (press) { getURL("http://www.makewing.com","_blank"); }
跳轉(zhuǎn)頁(yè)面代碼 <meta http-equiv="refresh" content="5;url=http://www.makewing.com">
細(xì)線分隔線 <hr noshade size=0 color=#C0C0C0>
網(wǎng)頁(yè)中的自動(dòng)換行 <td style="word-break:break-all">就搞定了。 完整的是 style="table-layout: fixed;WORD-BREAK: break-all; WORD-WRAP: break-word"
消除ie6自動(dòng)出現(xiàn)的圖像工具欄,設(shè)置 GALLERYIMG屬性為false或no . <IMG SRC="mypicture.jpg" HEIGHT="100px" WIDTH="100px" GALLERYIMG="no">
禁止頁(yè)面正文內(nèi)容被選取 <body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false"onmouseup="document.selection.empty()">
不能點(diǎn)右鍵,不用CTRL+A,不能復(fù)制作! <body oncontextmenu="window.event.returnValue=false" onkeypress="window.event.returnValue=false" onkeydown="window.event.returnValue=false" onkeyup="window.event.returnValue=false" ondragstart="window.event.returnValue=false" onselectstart="event.returnValue=false"> </body>
IE瀏覽器支持一個(gè) Body 屬性 bgproperties,它可以讓背景不滾動(dòng): <Body Background="圖片文件" bgproperties="fixed">
隨機(jī)變換背景圖象(一個(gè)可以刷新心情的特效) <Script Language="JavaScript"> image = new Array(4); //定義image為圖片數(shù)量的數(shù)組 image [0] = 'tu0.gif' //背景圖象的路徑 image [1] = 'tu1.gif' image [2] = 'tu2.gif' image [3] = 'tu3.gif' image [4] = 'tu4.gif' number = Math.floor(Math.random() * image.length); document.write("<BODY BACKGROUND="+image[number]+">"); </Script>
flash載入影片 on (release) { loadMovie("1-01.swf", "_root.loaderclip"); }
圖片表單按鈕 <form id="form1" name="form1" method="post" action=""> <img src="login.gif" width="62" height="22" onclick="document.form1.submit()" /> </form>
左右陰影背景的CSS定義方法 body { text-align:center; background-repeat: repeat-y; background-position: center; background-image: url(../images/bg.jpg); }
劃過(guò)鏈接 手型鼠標(biāo) style="cursor:hand"
如何關(guān)閉層 <div id="Layer1"></div> <a href="#" onClick="Layer1.style.display='none'">關(guān)閉層</a>
關(guān)閉窗口的腳本 <a href=javascript:close()>[關(guān)閉窗口]</a>
如果文字過(guò)長(zhǎng),則將過(guò)長(zhǎng)的部分變成省略號(hào)顯示 <DIV STYLE="width: 120px; height: 50px; border: 1px solid blue;overflow: hidden; text-overflow:ellipsis"> <NOBR>就是比如有一行文字,很長(zhǎng),表格內(nèi)一行顯示不下.</NOBR> </DIV>
進(jìn)入主頁(yè)后自動(dòng)最大化 <script> self.moveTo(0,0) self.resizeTo(screen.availWidth,screen.availHeight) </script>
凹陷文字 <div style="width:300px;padding:20px;overflow:hidden;word-wrap:break-word;word-break:break:all; font-size:12px; line-height:18px; background-color:#eeeeee;"> <font disabled> 怎么樣,我凹下去了吧?<br> 你不想試試嗎?<br> <a >www.lenvo.cn</a></font> </div>
運(yùn)行代碼框 <script> function Preview() {var TestWin=open(''); TestWin.document.write(code.value);} </script> <textarea id=code cols=60 rows=15></textarea> <br> <button onclick=Preview() >運(yùn)行</button>
給表格做鏈接 <table width="100%" onclick="window.open('http://www.makewing.com/', '_blank')" style="CURSOR:hand"> <tr> <td height="100" bgcolor="f4f4f4"> </td> </tr> </table>
讓彈出窗口總是在最上面 <body onblur="this.focus();">
CSS文字陰影 .shadowfont{FILTER: dropshadow(color=#666666, offx=1, offy=1, positive=1); FONT-FAMILY: "宋體"; FONT-SIZE: 9pt;COLOR: #ffffff;}
后退&關(guān)閉窗口 后退:javascript:history.back(1) 關(guān)閉:javascript:window.close();
表格透明 style="FILTER: alpha(opacity=72)"
如何避免別人把你的網(wǎng)頁(yè)放在框架中 <script language=“javascript”><!--if (self!=top){top.location=self.location;} -->< /script>
Alt和Title的區(qū)別 alt 用來(lái)給圖片來(lái)提示的。Title用來(lái)給鏈接文字或普通文字提示的。
<a href="#" Title="給鏈接文字提示">文字</a> <p Title="給鏈接文字提示">文字</p>
<img src="圖片鏈接" alt="給圖片提示">
所有的javascript的調(diào)用盡量采取外部調(diào)用 <SCRIPT LANGUAGE="javascript" SRC="js/xxxxx.js"></SCRIPT>
鏈接到 response.redirect"login.asp" location.href="xx.asp"
onClick="window.location='login.asp'" onClick="window.open('')"
基本鏈接樣式 a:link 表示鏈接的樣式 a:active 表示當(dāng)前活動(dòng)連接的樣式 a:hover 表示鼠標(biāo)劃過(guò)時(shí)的樣式 a:visited 表示已經(jīng)訪問(wèn)過(guò)的連接的樣式
"link-visited-hover-active" 簡(jiǎn)記為 "lvha" 即 "love"+"hate"
在同一頁(yè)面設(shè)置不同文字鏈接效果的樣式 <style type="text/css"> .green {COLOR: #309633} .green A:link {COLOR: #309633; TEXT-DECORATION: none} .green A:visited {COLOR: #309633; TEXT-DECORATION: none} .green A:hover {COLOR: #309633; TEXT-DECORATION: underline} .green A:active {COLOR: #309633; TEXT-DECORATION: none} </style> <a href="#" class="green">文字</a>
leafdesign 發(fā)表于 >2006-9-30 10:30:27 [全文] [評(píng)論] [引用] [推薦] [檔案] [推給好友] [收藏到網(wǎng)摘]
|