zoukankan      html  css  js  c++  java
  • 【十五分钟Talkshow】为什么新浪微博的输入文本框具有记忆功能

    摘要提示

    “十万个为什么” 之
        为什么在新浪微博上面的输入文本框有记忆功能?

        1.在网页关闭之前,如果文本框不为空,则将内容保存起来(保存到哪里去==>cookie)

        2.在网页加载的时候,想办法还原

    视频地址

    http://www.tudou.com/programs/view/DOkXpZQnnFw/

    示例代码

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplicationSample.Default" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style type="text/css">
            #txtInput {
                height: 113px;
                 694px;
            }
        </style>
        <script src="Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
        <script src="Scripts/jquery.cookie.js" type="text/javascript"></script>
    
        <script type="text/javascript">
    
            function SaveText() {
                var date = new Date();
                date.setTime(date.getTime() + (30 * 60 * 1000));
                $.cookie("input", $("#txtInput").text(), { expires: date });
            }
    
    
            $(function () {
                $("#txtInput").text($.cookie("input"));
            });
        
        </script>
    </head>
    <body onbeforeunload="SaveText()">
        <form id="form1" runat="server">
        <div>
            <textarea id="txtInput" rows="5"></textarea>
        </div>
        </form>
    </body>
    </html>
    
  • 相关阅读:
    spring3: Bean的命名与Bean的实例化
    极客软件测试52讲总结分享
    如何有效地搭建测试环境?
    用xshell 连接docker Linux服务器
    python+requests+excel+unittest+ddt接口自动化数据驱动并生成html报告
    CI持续集成系统环境--Gitlab+Gerrit+Jenkins完整对接
    jenkins 关联 钉钉机器人
    Jenkins pipeline 语法详解
    jenkins 添加 证书凭证Credentials
    项目中使用的S2SH整合中使用的struts.xml(参考模板)
  • 原文地址:https://www.cnblogs.com/chenxizhang/p/2373962.html
Copyright © 2011-2022 走看看