"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"
171.设置和使用cookie
<HTML>
<BODY>
设置与读取 cookies...<BR>
写入cookie的值<input type=text name=gg>
<INPUT TYPE = BUTTON Value = "设置cookie" onClick = "Set()">
<INPUT TYPE = BUTTON Value = "读取cookie" onClick = "Get()"><BR>
<INPUT TYPE = TEXT NAME = Textbox>
</BODY>
<SCRIPT LANGUAGE="JavaScript">
function Set()
{
var Then = new Date()
Then.setTime(Then.getTime() + 60*1000 ) //60秒
document.cookie = "Cookie1="+gg.value+";expires="+ Then.toGMTString()
}
function Get()
{
var cookieString = new String(document.cookie)
var cookieHeader = "Cookie1="
var beginPosition = cookieString.indexOf(cookieHeader)
if (beginPosition != -1)
{
document.all.Textbox.value = cookieString.substring(beginPosition + cookieHeader.length)
}
else
document.all.Textbox.value = "Cookie 未找到!"
}
</SCRIPT>
</HTML>//
172.取月的最后一天
function getLastDay(year,month)
{
//取年
var new_year = year;
//取到下一个月的第一天,注意这里传入的month是从1~12
var new_month = month++;
//如果当前是12月,则转至下一年
if(month>12)
{
new_month -=12;
new_year++;
}
var new_date = new Date(new_year,new_month,1);
return (new Date(new_date.getTime()-1000*60*60*24)).getDate();
}//
173.判断当前的焦点是组中的哪一个
for(var i=0;i<3;i++)
if(event.srcElement==bb[i])
break;//
174.实现类
package com.baosight.view.utils;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.http.HttpSession;
public class Mytag extends TagSupport
{
public int doStartTag() throws javax.servlet.jsp.JspException
{
boolean canAccess = false;
HttpSession session= pageContext.getSession();
if (canAccess)
{
return EVAL_BODY_INCLUDE;
}
else
{
return this.SKIP_BODY;
}
}
}
175.在web.xml中添加定义
<taglib>
<taglib-uri>guoguo</taglib-uri>
<taglib-location>/WEB-INF/abc.tld</taglib-location>
</taglib>
176.标签库中定义abc.tld
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>hr</shortname>
<uri>guoguo</uri>
<info>Extra 3 Tag Library</info>
<tag>
<name>mytag</name>
<tagclass>com.baosight.view.utils.Mytag</tagclass>
<attribute>
<name>id2</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
| 上一页 |
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] | 下一页 |
|