请问谁会用js写便条纸功能。
便条纸是什么东西,请描述一下。
希望大哥们给我提供一点代码或者例子来参考一下。在此,先谢谢了。

解决方案 »

  1.   

    我觉得便条就是一个提示性的小文档,有事件内容,事件的地点等。如果要用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>
      

  2.   

    就是能够存放临时消息的一个容器,MSNShell上有。QQ上有。一般的DeskTop ToolBar上都有的功能。就像便签那样,类似生活中经常用到的小黄纸,这个最好能够将数据持久化,JavaScript比较局限,就只能存在Cookies里面喽,楼上的代码不能分页,其实原理是很好的。