這篇文章帶給大家的內容是關於Dreamweaver中常用程式碼總結,有一定的參考價值,有需要的朋友可以參考一下,希望對你有幫助。
Dreamweaver常用程式碼:
1.控制橫向和縱向捲軸的顯隱?
<body style="overflow-y:hidden"> 去掉x轴 <body style="overflow-x:hidden"> 去掉y轴 <body scroll="no">不显
2.表格變色
<TD onmouseover="this.style.backgroundColor='#FFFFFF'" onmouseout="this.style.backgroundColor=''" style="CURSOR: hand">
3.禁止複製,滑鼠拖曳選取
<body ondragstart=window.event.returnValue=false oncontextmenu=window.event.returnValue=false onselectstart=event.returnValue=false>
4.普通iframe頁面
<iframe name="name" src="main.htm" width="450" height="287" scrolling="Auto" frameborder="0"></iframe>
5.iframe自適應高度
<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>
6.IE網址列前換成自己的圖示&可以在收藏夾中顯示出你的圖示
<link rel="Shortcut Icon" href="favicon.ico"> <link rel="Bookmark" href="favicon.ico">
7.字號縮放
越來越多的人長時間的泡網,眼鏡的普及率也越來越高,讓文字大點,讓更多的用戶看的更清楚。
<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>
8.簡單的跳轉網頁程式碼
如果你要讓頁面顯示3秒鐘之後跳轉,可以在html程式碼的
< ;/head>部分加上這樣的程式碼:<meta http-equiv="refresh" content="3; url=http://www.php.cn">
9.iframe(嵌入式幀)自適應高度
填寫的嵌入位址一定要和本頁面在同一個網站上,否則會提示「拒絕造訪!」。對跨域引用有權限問題,請查閱其他資料。
<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>
10.跳轉選單新視窗
<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>
11.flash透明選項
<param name="wmode" value="transparent">
12.新增至收藏夾和設定為首頁
<a href=# onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('设为首页" _href="http://www.php.cn/');">设为首页</a> <a href="javascript:window.external.AddFavorite('http://www.php.cn/','php中文网')">收藏本站</a>
<script language=JavaScript> document.write("最后更新时间: " + document.lastModified + "") </script>
14.節日倒數
<Script Language="JavaScript"> var timedate= new Date("October 1,2002"); var times= "国庆节"; var now = new Date(); var date = timedate.getTime() - now.getTime(); var time = Math.floor(date / (1000 * 60 * 60 * 24)); if (time >= 0) document.write( "现在离"+times+"还有: "+time +"天") </Script>
<meta http-equiv="Expires" CONTENT="0"> <meta http-equiv="Cache-Control" CONTENT="no-cache"> <meta http-equiv="Pragma" CONTENT="no-cache">
<iframe src="about:<body style='background:transparent'>" allowtransparency></iframe>17.打开窗口即最大化 <script language="JavaScript"> <!-- Begin self.moveTo(0,0) self.resizeTo(screen.availWidth,screen.availHeight) // End --> </script>
<bgsound src="mid/windblue[1].mid" loop="-1"> 只适用于IE <embed src="music.mid" autostart="true" loop="true" hidden="true"> 对Netscape ,IE 都适用
<marquee direction=up height=146 onmouseout=start() onmouseover=stop() scrollAmount=2>滚动信息</marquee>
20.防止點擊空連結時,頁面往往會重置到頁首端
程式碼「javascript:void(null)」取代原來的「#」標記
21.文字或圖片彈出指定大小的視窗
在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>
<meta http-equiv="refresh" content="5;url=http://www.php.cn/">
<hr noshade size=0 color=#C0C0C0>
<td style="word-break:break-all">
style="table-layout: fixed;WORD-BREAK: break-all; WORD-WRAP: break-word"
<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()">
<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>
<Body Background="图片文件" bgproperties="fixed">
<Script Language="JavaScript"> image = new Array(4); //定义image为图片数量的数组 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>
<form id="form1" name="form1" method="post" action=""> <img src="login.gif" width="62" height="22" onclick="document.form1.submit()" /> </form>
body { text-align:center; background-repeat: repeat-y; background-position: center; background-image: url(../images/bg.jpg); }
style="cursor:hand"
<div id="Layer1"></div> <a href="#" onClick="Layer1.style.display='none'">关闭层</a>
<a href=javascript:close()>[关闭窗口]</a>
<DIV STYLE="width: 120px; height: 50px; border: 1px solid blue;overflow: hidden; text-overflow:ellipsis"> <NOBR>就是比如有一行文字,很长,表格内一行显示不下.</NOBR> </DIV>
#
<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>
你不想試試嗎?
<a href="http://www.lenvo.cn/">www.lenvo.cn</a></font> </div>
<script> function Preview() {var TestWin=open(''); TestWin.document.write(code.value);} </script> <textarea id=code cols=60 rows=15></textarea> <br> <button onclick=Preview() >运行</button>
<table width="100%" onclick="window.open('http://www.makewing.com/', '_blank')" style="CURSOR:hand"> <tr> <td height="100" bgcolor="f4f4f4"> </td> </tr> </table>
.shadowfont{FILTER: dropshadow(color=#666666, offx=1, offy=1, positive=1); FONT-FAMILY: "宋体"; FONT-SIZE: 9pt;COLOR: #ffffff;}
後退:javascript:history.back(1)
關閉:javascript:window.close();
##
style="FILTER: alpha(opacity=72)"
<script language=“javascript”><!--if (self!=top){top.location=self.location;} -->< /script>
alt 用來給圖片來提示的。 Title用來給連結文字或普通文字提示的。
<a href="#" Title="给链接文字提示">文字</a> <p Title="给链接文字提示">文字</p> <img src="图片链接" alt="给图片提示">
<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 表示當前活動連接的樣式a:hover 表示滑鼠劃過時的樣式
a:visited 表示已經訪問過的連接的樣式
"link-visited-hover-active" 簡記為"lvha" 即"love" "hate"
49.在同一頁面設定不同文字連結效果的樣式
<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>
<select name=select onchange="javascript:window.open(this.options[this.selectedIndex].value)"style="color:#333"> <option>----请选择----</option> <option value="http://www.webkkk.com">站长设计网</option> <option value="http://www.makewing.com/store/">MakeWing Store</option> <option value="http://www.izhu.com/">爱烛网</option> </select>
<iframe src="javascript:false" scrolling="no" frameborder="0" style="z-index:-1;position:absolute; top:5px; left:2px;width:168;height:100px;"></iframe>
<base target="_blank">
以上是Dreamweaver中常用程式碼總結的詳細內容。更多資訊請關注PHP中文網其他相關文章!