文件類型 <HTML></HTML> (放在檔案的開頭與結尾)
文件主題 <TITLE></TITLE> (必須放在「文頭」區塊內)
文頭 <HEAD></HEAD> (描述性資料,像是「主題」)
文體 <BODY></BODY> (文件本體)
(由瀏覽器控制的顯示風格)
標題 <H?></H?> (從1到6,有六層選擇)
標題的對齊 <H? ALIGN=LEFT|CENTER|RIGHT></H?>
區分 <DIV></DIV>
區分的對齊 <DIV ALIGN=LEFT|RIGHT|CENTER|JUSTIFY></DIV>
引文區塊 <BLOCKQUOTE></BLOCKQUOTE> (通常會內縮)
強調 <EM></EM> (通常會以斜體顯示)
特別強調 <STRONG></STRONG> (通常會以加粗顯示)
引文 <CITE></CITE> (通常會以斜體顯示)
碼 <CODE></CODE> (顯示原始碼之用)
樣本 <SAMP></SAMP>
鍵盤輸入 <KBD></KBD>
變數 <VAR></VAR>
定義 <DFN></DFN> (有些瀏覽器不提供)
地址 <ADDRESS></ADDRESS>
大字 <BIG></BIG>
小字 <SMALL></SMALL>
與外觀相關的標籤(作者自訂的表現方式)
加粗 <B></B>
斜體 <I></I>
底線 <U></U> (尚有些瀏覽器不提供)
刪除線 <S></S> (尚有些瀏覽器不提供)
下標 <SUB></SUB>
上標 <SUP></SUP>
打字機體 <TT></TT> (用單空格字型顯示)
預定格式 <PRE></PRE> (保留文件中空格的大小)
預定格式的寬度 <PRE WIDTH=?></PRE>(以字元計算)
向中看齊 <CENTER></CENTER> (文字與圖片都可以)
閃耀 <BLINK></BLINK> (有史以來最被嘲弄的標籤)
字體大小 <FONT SIZE=?></FONT>(從1到7)
改變字體大小 <FONT SIZE=+|-?></FONT>
基本字體大小 <BASEFONT SIZE=?> (從1到7; 內定爲3)
字體顏色 <FONT COLOR="#$$$$$$"></FONT>
說明 <!-- *** --> (瀏覽器不會顯示)
<!--修改滾動條-->
<style type="text/css">
body {
scrollbar-face-color: #330033;
scrollbar-shadow-color: #FFFFFF;
scrollbar-highlight-color: #FFFFFF;
scrollbar-3dlight-color: #FFFFFF;
scrollbar-darkshadow-color: #FFFFFF;
scrollbar-track-color: #330033;
scrollbar-arrow-color: #FFFFFF;
}
</style>
<!--修改滾動條結束-->
將上面的代碼放在葉子代碼的<head></head>之間,顏色可根據自己的需要修改。
滾動條的代碼意思如下:
Scrollbar-Face-Color爲滾動條表面顏色設定;
Scrollbar-Track-Color爲滾動條底板顏色設定;
Scrollbar-Darkshadow爲滾動條下邊和右邊邊沿顏色設定;
Scrollbar-Highlight-Color爲滾動條上斜面和左斜面顏色設定;
Scrollbar-Shadow-Color爲滾動條下斜面和右斜面顏色設定;
Scrollbar-3Dlight-Color爲滾動條上邊和左邊的邊沿顏色設定;
Scrollbar-Arrow-Color爲滾動條兩端箭頭顏色設定。
<!> 跑馬燈
<marquee>...</marquee>普通捲動
<marquee behavior=slide>...</marquee>滑動
<marquee behavior=scroll>...</marquee>預設捲動
<marquee behavior=alternate>...</marquee>來回捲動
<marquee direction=down>...</marquee>向下捲動
<marquee direction=up>...</marquee>向上捲動
<marquee direction=right></marquee>向右捲動
<marquee direction=’left’></marquee>向左捲動
<marquee loop=2>...</marquee>捲動次數
<marquee width=180>...</marquee>設定寬度
<marquee height=30>...</marquee>設定高度
<marquee bgcolor=FF0000>...</marquee>設定背景顏色
<marquee scrollamount=30>...</marquee>設定捲動距離
<marquee scrolldelay=300>...</marquee>設定捲動時間
1)貼圖:<img src="圖片地址"> 8)字體刪除線: <s>寫上你想寫的字</s> 9)字體加大: <big>寫上你想寫的字</big> 1、店鋪音樂代碼:音樂網址" loop="-1"> 簡單常用HTML代碼大全(修改網頁必備) 網頁常用HTML代碼大全 |
進入網頁時彈出的信息對話框
<body >
關閉窗口後彈出對話框
<body >
告別提示
<body nUnload= alert("再見,感謝你的訪問!")>
只要你肯幹,沒有什麼不能成功的.
1。忽視右鍵
<body ncontextmenu="return false">
或
<body style="overflow-y:hidden">
2。加入背景音樂
IE:<bgsound src="*.mid" loop=infinite>
NS:<embed src="*.mid" autostart=true hidden=true loop=true>
</embed>
*.mid你的背景音樂的midi格式文件
3。簡單的window.open方法
<a href="#"
nclick="javascript:window.open(文件路徑/文件名,newwindow,
toolbar=no,scrollbars=yes,resizable=no,top=0,left=0,
width=400,height=300);">文字或圖片</a>
參數解釋:
<SCRIPT. LANGUAGE="javascript"> js腳本開始;
window.open 彈出新窗口的命令;
文件路徑/文件名 彈出窗口的文件名;
newwindow 彈出窗口的名字(不是文件名),非必須,可用空代替;
width=400 窗口寬度;
height=300 窗口高度;
top=0 窗口距離屏幕上方的象素值;
left=0 窗口距離屏幕左側的象素值;
toolbar=no 是否顯示工具欄,yes爲顯示;
menubar,scrollbars 表示菜單欄和滾動欄。
resizable=no 是否允許改變窗口大小,yes爲允許;
location=no 是否顯示地址欄,yes爲允許;
status=no 是否顯示狀態欄內的信息(通常是文件已經打開),yes爲允許;
</SCRIPT> js腳本結束
4。簡單的頁面加密
<script. LANGUAGE="javascript">
<!--
function loopy(){
var sWord ="";
while(sWord!="login"){sWord=prompt("請輸入你的登陸密碼");}
alert("登陸成功!");
}
loopy()
//-->
</script>
5。拉動頁面時背景圖不動
<style>
body{background-image:url(logo.gif);
background-repeat:no-repeat;background-position:center}
</style>
6。讓瀏覽器在保存頁面時保存失敗
<NOSCRIPT><iframe. src="*.html"></iframe></NOSCRIPT>
7。隨機替換圖片
<script>
document.write(<img src="img/+parseInt(Math.random()*(5))
+.gif"height="40" width="50">
</script>
圖片文件名爲0.gif 1.gif 2.gif 3.gif 4.gif
8。窗口定時關閉
先將如下代碼網頁文件的區:
<script. language="javascript">
function closeit() { setTimeout("self.close()",10000) //毫秒 }
</script>
然後再在<body>標內加入如:<body nload="closeit()">
9。網頁自動關閉
<html>
<head>
<object id=closes type="application/x-oleobject"
classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close">
</object>
</head>
<body nload="window.setTimeout(closes.Click(),10000)">
這個窗口會在10秒過後自動關閉,而且不會出現提示.
</body>
</html>
10。網頁自動刷新
在head部記入
<META. HTTP-EQUIV="Refresh" content="20">
其中20爲20秒後自動刷新,你可以更改爲任意值。
11。網頁自動轉頁
<META. HTTP-EQUIV="Refresh" CONTENT="時間(秒);URL=地址">
12。保持layer在最前面,而不被Iframe、Object所覆蓋
在Layer中再插Iframe. 或 Object 設z-Index值
<div z-Index:2><object xxx></object> # 前面
<div z-Index:1><object xxx></object> # 後面
<div id="Layer2" style="position:absolute; top:40;width:400px;
height:95px;z-index:2"> height=100% width=100%>
<iframe. width=0 height=0></iframe>
</div>
<div id="Layer1" style="position:absolute; top:50;width:200px;
height:115px;z-index:1">
<iframe. height=100% width=100%></iframe>
</div>
13。返回上一頁
<a href=javascript:history.back(1)>『返回上一頁』</a>
14。關閉窗口
<a href=javascript:self.close()>『關閉窗口』</a>
15。關於iframe的透明背景
<IFRAME. ID="iFrame1" SRC="iframe.htm"
allowTransparency="true"
style="background-color: green"></IFRAME>
16. ncontextmenu="window.event.returnValue=false" 將徹底屏蔽鼠標右鍵
<table border ncontextmenu=return(false)><td>no</table> 可用於Table
17. <body nselectstart="return false"> 取消選取、防止複製
18.οnpaste="return false" 不準粘貼
19.οncοpy="return false;" ncut="return false;" 防止複製
20. <link rel="Shortcut Icon" href="favicon.ico"> IE地址欄前換成自己的圖標
21. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夾中顯示出你的圖標
22. <input style="ime-mode:disabled"> 關閉輸入法
23. 永遠都會帶着框架
<script. language="JavaScript"><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm爲框架網頁
// --></script>
24. 防止被人frame.
<SCRIPT. LANGUAGE=JAVASCRIPT><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>
25. 網頁將不能被另存爲
<noscript><iframe. src=*.html></iframe></noscript>
26. 查看網頁源代碼
<input type=button value=查看網頁源代碼
οnclick="window.location = "view-source:"+ "http://www.pconline.com.cn"">
27.刪除時確認
<a href="javascript:if(confirm("確實要刪除嗎?"))location="boos.asp? &areyou=刪除&page=1"">刪除</a>
28.屏蔽功能鍵Shift,Alt,Ctrl
<script>
function look(){
if(event.shiftKey)
alert("禁止按Shift鍵!"); //可以換成ALT CTRL
}
document.οnkeydοwn=look;
</script>
29. 網頁不會被緩存
<META. HTTP-EQUIV="pragma" CONTENT="no-cache">
<META. HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META. HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META. HTTP-EQUIV="expires" CONTENT="0">
30.怎樣讓表單沒有凹凸感?
<input type=text style="border:1 solid #000000">
或 <input type=text style="border-left:none; border-right:none; border -top:none; border-bottom: 1 solid #000000"></textarea>
31.不要滾動條?
讓豎條沒有:
<body style="overflow:scroll;overflow-y:hidden">
</body>
讓橫條沒有:
<body style="overflow:scroll;overflow-x:hidden">
</body>
兩個都去掉?更簡單了
<body scroll="no">
</body>
32.怎樣去掉圖片鏈接點擊後,圖片周圍的虛線?
<a href="#" nFocus="this.blur()"><img src="logo.jpg" border=0></a>
33.電子郵件處理提交表單
<form. name="form1" method="post" action="mailt****@***.com" enctype="text/plain">
<input type=submit>
</form>
34.在打開的子窗口刷新父窗口的代碼裏如何寫?
window.opener.location.reload()
35.如何設定打開頁面的大小
<body nload="top.resizeTo(300,200);">
打開頁面的位置<body nload="top.moveBy(300,200);">
36.在頁面中如何加入不是滿鋪的背景圖片,拉動頁面時背景圖不動
<STYLE>
body
{background-image:url(logo.gif); background-repeat:no-repeat;
background-position:center;background-attachment: fixed}
</STYLE>
37. 檢查一段字符串是否全由數字組成
<script. language="Javascript"><!--
function checkNum(str){return str.match(//D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>
38. 獲得一個窗口的大小
document.body.clientWidth; document.body.clientHeight
39. 怎麼判斷是否是字符
if (/[^/x00-/xff]/g.test(s)) alert("含有漢字");
else alert("全是字符");
40.TEXTAREA自適應文字行數的多少
<textarea rows=1 name=s1 cols=27 npropertychange="this.style.posHeight=this.scrollHeight">
</textarea>
41. 日期減去天數等於第二個日期
<script. language=Javascript>
function cc(dd,dadd)
{
//可以加上錯誤處理
var a = new Date(dd)
a = a.valueOf()
a = a - dadd * 24 * 60 * 60 * 1000
a = new Date(a)
alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日")
} cc("12/23/2002",2)
</script>
42. 選擇了哪一個Radio
<HTML><script. language="vbscript">
function checkme()
for each ob in radio1
if ob.checked then window.alert ob.value
next
end function
</script><BODY>
<INPUT name="radio1" type="radio" value="style" checked>Style.
<INPUT name="radio1" type="radio" value="barcode">Barcode
<INPUT type="button" value="check" nclick="checkme()">
</BODY></HTML>
43.腳本永不出錯
<SCRIPT. LANGUAGE="JavaScript">
<!-- Hide function killErrors(){return true;} window.onerror = killErrors; // -->
</SCRIPT>
44.ENTER鍵可以讓光標移到下一個輸入框
<input nkeydown="if(event.keyCode==13)event.keyCode=9">
45. 檢測某個網站的鏈接速度:
把如下代碼加入<body>區域中:
<script. language=Javascript>
tim=1
setInterval("tim++",100)
b=1
var autourl=new Array()
autourl[1]="www.njcatv.net"
autourl[2]="javacool.3322.net"
autourl[3]="www.sina.com.cn"
autourl[4]="www.nuaa.edu.cn"
autourl[5]="www.cctv.com"
function butt(){
document.write("<form. name=autof>")
for(var i=1;i<autourl.length;i++)
document.write("<input type=text name=txt"+i+" size=10 value=測試中
……> =》<input type=text
name=url"+i+" size=40> =》<input type=button value=GO
οnclick=window.open(this.form.url"+i+".value)><br>")
document.write("<input type=submit value=刷新></form>")
}
butt()
function auto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value="鏈接超時"}
else
{document.forms[0]["txt"+b].value="時間"+tim/10+"秒"} b++ }
function run(){for(var i=1;i<autourl.length;i++)document.write("<img src=http://"+autourl+"/"+Math.random()+" width=1 height=1 nerror=auto("http://"+autourl+"")>")}
run()</script>
46. 各種樣式的光標
auto :標準光標
default :標準箭頭
hand :手形光標
wait :等待光標
text :I形光標
vertical-text :水平I形光標
no-drop :不可拖動光標
not-allowed :無效光標
help :?幫助光標
all-scroll :三角方向標
move :移動標
crosshair :十字標
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize
47、禁止鼠標右鍵,把Demo的圖片全都設爲表格的背景,表格的大小與圖片的大小一樣。這樣做看起來是一樣的,主要是防止鼠標經過圖片時會出現另存的按鈕。禁止鼠標右鍵的代碼很簡單:<script. LANGUAGE="JavaScript"> function click() { if (event.button==2) {alert('呵呵,不好意思,你甭想使用右鍵下載圖片:)'); } } document.οnmοusedοwn=click</script> |