HTC入門樣本(二)
<!--*****************input.htc******************-->
<script>
switch(type)
{
case 'text':
case 'password': //文本輸入框和密碼輸入框的樣式
style.border="1px solid #000000";
style.backgroundColor="#FFFFFF";
style.height="18px";
style.font="normal 12px 宋體";
style.color="#000000";
break;
case 'submit':
case 'reset':
case 'button': //按鈕類的樣式(不包括圖片按鈕)
style.border="1px solid #000000";
style.backgroundColor="#CCCCCC";
style.height="18px";
style.font="normal 12px 宋體";
style.color="#000000";
break;
default: //對於象單選框多選框等上面沒有出現過的元素,我們使用預設樣式。
;
}
</script>
<!--**************************Demo2.html***************************************-->
<head>
<title>用HTC統一定製表單樣式執行個體</title>
<style type=text/css>
body { font:normal 14px 宋體; }
input { behavior:url('input.htc'); }
</style>
</head>
<body>
<form>
文字框: <input type=text><br><br>
密碼輸入框:<input type=password><br><br>
檔案選擇框:<input type=file><br><br>
單選框: <input type=checkbox><br><br>
多選框: <input type=radio><br><br>
提交按鈕: <input type=submit value=提交><br><br>
重設按鈕: <input type=reset value=重設><br><br>
普通按鈕: <input type=button value=返回><br><br>
圖片銨鈕: <input type=image src=button.gif>
</form>
</body>
注意:首先你得找一張名為“button.gif”的圖片。
這個樣本更多的表現了HTC對樣式的支援,給人以新的感覺,HTC檔案也可以這樣學。沒有對象,沒有事件,沒有方法。