过期作废 发表于 2007-4-27 11:27:55

***综合类***在页面上添加表项

把下列代码加到网页的<body></body>标签之间 从google下载我的照片管理软件
要完成此效果需要两个步骤

第一步:把如下代码加入到<head>区域中

<script>
var expdays = 30;
var exp = new date();
exp.settime(exp.gettime() + (expdays*24*60*60*1000));
var showcount = 0;
var swapcolour;
function listtodoitems() {
var numtodoitems = getcookie('pt_numtodolist');
var i;
var todoitem;
if (numtodoitems == null) {
numtodoitems = 0;
}
showcount = 0; swapcolour = 0;
for (i=1; i <= numtodoitems; i++) {
todoitem = getcookie('pt_todoitem'+i);
if (todoitem != null) {
printitem(todoitem, i);
      }
   }
}
function deleteitem(count) {
deletecookie('pt_todoitem'+count);
window.location = window.location;
}
function printitem (todoitem, count) {
var color = "";
swapcolour = 1 - swapcolour;

if (swapcolour==1) {color = "bgcolor='#cococo'"} ;
showcount++;
document.write("<tr " + color + ">");
document.write("<td width=10% align=center valign=top><small><b>"+showcount);
document.write("<td width=75% align=left><small>"+todoitem);
document.write("<td width=15% align=center><small>"+"<a href='javascript:deleteitem(" + count + ")'>delete</a>");
}
function additem() {
var numtodoitems = getcookie('pt_numtodolist');
var i;
var todoitem;
if (numtodoitems == null) {
numtodoitems = 0;
}
todoitem = prompt("enter new item");
if ((todoitem != null) && (todoitem != "undefined" )) {
numtodoitems++;
setcookie('pt_todoitem'+numtodoitems, todoitem, exp);
setcookie('pt_numtodolist',numtodoitems, exp);
window.location = window.location;
   }
}
function set() {
visitorname = prompt("who are you?");
setcookie ('visitorname', visitorname, exp);
setcookie ('wwhcount', 0, exp);
setcookie ('wwhenh', 0, exp);
}
function getcookieval (offset) {
var endstr = document.cookie.indexof (";", offset);
if (endstr == -1)   
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function getcookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {   
var j = i + alen;   
if (document.cookie.substring(i, j) == arg)      
return getcookieval (j);   
i = document.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 : null;
var path = (argc > 3) ? argv : null;
var domain = (argc > 4) ? argv : null;
var secure = (argc > 5) ? argv : false;
document.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();
exp.settime (exp.gettime() - 1);
var cval = getcookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.togmtstring();
}
</script>


第二步:把如下代码加入到<body>区域中

<center>
<b><big><font color="#999999">列表</font></big></b>
<center><b></b>
<hr><br>
<table width=100%>
<script>
listtodoitems();
</script>
</table>
<br><hr>
<center>
<a href="javascript:additem()">添加</a>
</center>
      










--------------------------------------

拥有三人行论坛管理系列软件,一个人就可以管理一个论坛的更新维护。还能使您的论坛有千人在线的真实火暴效果,让您不在为论坛因没有人气而留不住会员而烦恼,使您的论坛早日成为一流的论坛。详情请登陆网站:http://www.cnsrx.cn 三人行论坛管理软件,站长必备的专业好工具。(您使用的是免费版本,购买收费版本后,将不带广告。业务QQ:247216 44985227)
页: [1]
查看完整版本: ***综合类***在页面上添加表项