js做便条纸 请问谁会用js写便条纸功能。便条纸是什么东西,请描述一下。希望大哥们给我提供一点代码或者例子来参考一下。在此,先谢谢了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我觉得便条就是一个提示性的小文档,有事件内容,事件的地点等。如果要用js实现的话,我觉得可以采用Cookie技术。可以设置内容,和有效时间等属性<html> <head> <style type="text/css"> *{ font-size:12px; font-family:宋体,Arial; font-weight:normal; color:#333; } textarea{ width:100%; height:98%; border:1px solid black; } </style> <script type="text/javascript"> function read_cookie(key){ var str, ary; str = document.cookie; ary = str.replace(/ *; */g, ";").split(";"); key = escape(key) + "="; for(var i = 0; i < ary.length; i++){ if(ary[i].indexOf(key) == 0){ return (unescape(ary[i].split("=")[1])); } } } function write_cookie(key, value,cookieDomain, cookiePath, expireTime,targetWindow){ //value表示你的时间内容,expireTime表示有效时间 var strAppendix = ""; strAppendix += cookieDomain?";domain="+cookieDomain:""; strAppendix += cookiePath?";path="+cookiePath:""; strAppendix += expireTime?";expires="+expireTime:""; targetWindow = targetWindow?targetWindow:top; targetWindow.document.cookie = escape(key) + "=" +escape(value)+strAppendix; } function loadDate(){ if(read_cookie("txt1")){ $("txt1").value = read_cookie("txt1"); } } function saveDate(){ var dt = new Date(); dt.setDate(dt.getDate()+1); write_cookie("txt1",$("txt1").value,false,false,dt.toUTCString()); } function $(str){ return document.getElementById(str); } </script> </head> <body onload="loadDate();" onunload="saveDate();"> <textarea id = "txt1">在这里输入内容,关闭页面再次打开,修改后的内容依然存在</textarea> </body></html> 就是能够存放临时消息的一个容器,MSNShell上有。QQ上有。一般的DeskTop ToolBar上都有的功能。就像便签那样,类似生活中经常用到的小黄纸,这个最好能够将数据持久化,JavaScript比较局限,就只能存在Cookies里面喽,楼上的代码不能分页,其实原理是很好的。 求大神解答,td指定位置移动及拖拽后事件丢失问题,在线等,我好答案马上结贴 在线等 。。。。。 JavaScript 如何实现去掉当前网页的工具栏 菜单栏和地址栏 如何让联动下拉框选择一下可以显示其VAILUA的值 非常诡异的三段代码,哪位可以告诉我为什么会这样![附:网上演示] 如何获取某个表格里面的所有表单控件?急,在线等! 时间计算问题,很简单 如何取到鼠标点到的table的行和列的值? 关于frame相互访问的问题 怎么设定<select>的当前值! 像这样的横向菜单怎么写出来? Div的大小控制
有效时间等属性<html>
<head>
<style type="text/css">
*{
font-size:12px;
font-family:宋体,Arial;
font-weight:normal;
color:#333;
}
textarea{
width:100%;
height:98%;
border:1px solid black;
}
</style>
<script type="text/javascript">
function read_cookie(key){
var str, ary;
str = document.cookie;
ary = str.replace(/ *; */g, ";").split(";");
key = escape(key) + "=";
for(var i = 0; i < ary.length; i++){
if(ary[i].indexOf(key) == 0){
return (unescape(ary[i].split("=")[1]));
}
}
}
function write_cookie(key, value,cookieDomain, cookiePath, expireTime,targetWindow){
//value表示你的时间内容,expireTime表示有效时间
var strAppendix = "";
strAppendix += cookieDomain?";domain="+cookieDomain:"";
strAppendix += cookiePath?";path="+cookiePath:"";
strAppendix += expireTime?";expires="+expireTime:"";
targetWindow = targetWindow?targetWindow:top;
targetWindow.document.cookie = escape(key) + "=" +escape(value)+strAppendix;
}
function loadDate(){
if(read_cookie("txt1")){
$("txt1").value = read_cookie("txt1");
}
}
function saveDate(){
var dt = new Date();
dt.setDate(dt.getDate()+1);
write_cookie("txt1",$("txt1").value,false,false,dt.toUTCString());
}
function $(str){
return document.getElementById(str);
}
</script>
</head>
<body onload="loadDate();" onunload="saveDate();">
<textarea id = "txt1">在这里输入内容,关闭页面再次打开,修改后的内容依然存在</textarea>
</body>
</html>