zoukankan      html  css  js  c++  java
  • timer 焦点

    function txtFocus()
            {
                var exp=new Date();
                exp.setTime(exp.getTime() + 60*60*1000);
                document.cookie = "focusTextBox="+ event.srcElement.id + ";expires=" + exp.toGMTString();
            }


               <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <div>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server" OnInit="UpdatePanel1_Init">
                    <ContentTemplate>
                    <asp:TextBox runat=server ID=zwei Columns="10" Rows="10" TextMode="MultiLine"></asp:TextBox>
                        <asp:Timer ID="Timer1" runat="server" Interval="5000">
                        </asp:Timer>
                    </ContentTemplate>
                </asp:UpdatePanel>
           
           
            </div>

    protected void Page_Load(object sender, EventArgs e)
        {
            this.zwei.Attributes.Add("onfocus","txtFocus()");
        }
        protected void UpdatePanel1_Init(object sender, EventArgs e)
        {
            if (this.Request.Cookies["focusTextBox"] != null)
            {
                string s = this.Request.Cookies["focusTextBox"].Value;//读出post之前光标停留在哪个TextBox之中
                string script =
                "var inp = $get('" + s + "');" +
                "window.setTimeout('var r = inp.createTextRange();r.collapse(false);r.select();', 10);";
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.Page.GetType(), "ScriptBlock", script, true);
            }

        }

  • 相关阅读:
    9个offer,12家公司,35场面试,从微软到谷歌,应届计算机毕业生的2012求职之路(转)
    Path Sum(参考别人,二叉树DFS)
    tcp/ip
    常见Unix指令
    Pascal's Triangle II
    Implement strStr()
    LeetCode总结
    从LLVM源码学C++(一)
    面试题:1到N中,1出现的次数
    面试题:数组划分成两个子数组,和的差值的绝对值最小
  • 原文地址:https://www.cnblogs.com/zwei1121/p/1238791.html
Copyright © 2011-2022 走看看