网页经典代码(五)
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属性那样,可以进行正常的数值传递
新闻热点
疑难解答