網頁經典代碼(五)
30.自動更新提示
<body>
<TABLE border=2 cellspacing=0 cellpadding=3>
<TR><TD bgcolor="#000044">
<FONT color="#4400ff" face=georgia,arial size=+1>
<CENTER>
<SCRIPT LANGUAGE="javascript">
<!--
document.write(document.title);
//-->
</SCRIPT>
</TD></TR>
<TR><TD bgcolor="#440000">
<FONT size=-1 color="#ff0000" face="trebuchet MS","arial">
<SCRIPT LANGUAGE="javascript">
<!-- Begin
function getCookieVal (offset) {
var endstr = documents.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = documents.cookie.length;
return unescape(documents.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = documents.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (documents.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = documents.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
documents.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie(name) {
var exp = new Date();
FixCookieDate (exp);
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
if (cval != null)
documents.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var cookie_date=new Date(document.lastModified);
var expdate = new Date();
expdate.setTime(expdate.getTime()+(5*24*60*60*1000));
document.write("<Font color=ff8800>" + "上次更新時間: "+ "</font>" +document
.lastModified);
document.write("");
if (!(cookie_date == GetCookie("cookie_date"))){
SetCookie("cookie_date",cookie_date,expdate);
document.write("<font color='yellow'>
站點上次更新!</font>
");
}
// End -->
</SCRIPT>
</FONT>
</TD></TR>
</TABLE>
</CENTER>
</body>
31.關于表格提交的幾種格式
<input type=text name=txtPostalCode onKeypress="if (event.keyCode < 45 || ev
ent.keyCode > 57) event.returnvalue = false;">
限制輸入字符,你可以改變KEYCODE的值來限制輸入。你將KEYCODE的值設為極大和極小
就什么也不能輸入了。這個可以屏蔽你想屏蔽的字符有一定的選擇性..
<INPUT type="text" name="username" value="james" disabled>
使用disabled屬性后的區域的值,不能被傳遞給其他的程序(ASP/CGI)去處理,如果你
非要傳遞請通過隱藏屬性去做。這個比較單一,功能不強。一般用于未完成的站點。
<INPUT type="text" name="partNumber" value="1500" readonly>
readonly屬性顧名思義是“只讀”。它將TEXT轉化為一個對象,禁止對它進行編輯。你
雖然可以通過TAB鍵在多個TEXT區域間切換,但是不能修改已經指定的TEXT區的值。但是
它不象Disabled屬性那樣,可以進行正常的數值傳遞
新聞熱點
疑難解答