s="http://www.9499.net/page1.htm" s=s.replace(/(.*\/){0,}([^\.]+).*/ig,"$2") alert(s) /////////利用正则表达式限制网页表单里的文本框输入内容: 用正则表达式限制只能输入中文:onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,'') )" 用正则表达式限制只能输入全角字符: onkeyup="value=value.replace(/[^\uFF00-\uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\uFF00-\uFFFF]/g,'') )" 用正则表达式限制只能输入数字:onkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" 用正则表达式限制只能输入数字和英文:onkeyup="value=value.replace(/[\W]/g,'') "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; } } } |