Topic: web开发常用js功能,希望大家都来扩充,众人拾柴火焰高

  Print this page

1.web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 13:54

今天高兴,拿些小玩意给大家分享,让大家以后工作便利些.最好是大家都来参加,众人拾柴火焰高嘛[/color]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>

</HEAD>

<BODY>
<FORM METHOD=POST ACTION="">
<input onpaste="return false;" type="text" name="textfield" style="width:400px; ime-mode:disabled" value=" English only">
</FORM>
</BODY>
</HTML>

2.e mail 合法性检查 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 13:57

function check()
{
if(document.register.email.value.length!=0)
{
if (document.register.email.value.charAt(0)=="." ||
document.register.email.value.charAt(0)=="@"||
document.register.email.value.indexOf('@', 0) == -1 ||
document.register.email.value.indexOf('.', 0) == -1 ||
document.register.email.value.lastIndexOf("@")   
  ==document.register.email.value.length-1 ||
document.register.email.value.lastIndexOf(".")
==document.register.email.value.length-1)
{
alert("Email的格式不正確!");
document.register.email.focus();
return false;
}
}
else
{
alert("Email的不能为空!");
document.register.email.focus();
return false;
}
return false;
}

3.页面右键屏蔽 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 13:59

<body oncontextmenu="return false">

4.右键菜单的淡入淡出效果 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:01

右键菜单的淡入淡出效果
<HTML><HEAD><TITLE>右键菜单的淡入淡出效果</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<SCRIPT language=JavaScript>
<!-- // RightClickMenu
var intDelay=10; //设置菜单显示速度,越大越慢
var intInterval=5; //每次更改的透明度
function showmenuie5(){
var rightedge=document.body.clientWidth-event.clientX
var bottomedge=document.body.clientHeight-event.clientY
if (rightedge<ie5menu.offsetWidth)
ie5menu.style.left=document.body.scrollLeft+event.clientX-ie5menu.offsetWidth
else
ie5menu.style.left=document.body.scrollLeft+event.clientX
if (bottomedge<ie5menu.offsetHeight)
ie5menu.style.top=document.body.scrollTop+event.clientY-ie5menu.offsetHeight
else
ie5menu.style.top=document.body.scrollTop+event.clientY
ie5menu.style.visibility="visible"
//ie5menu.style.visibility=""
ie5menu.filters.alpha.opacity=0
GradientShow()
return false
}
function hidemenuie5(){
//ie5menu.style.visibility="hidden"
GradientClose()
}
function highlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
}
}
function lowlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="#000000"
}
}
function jumptoie5(){
if (event.srcElement.className=="menuitems"){
if (event.srcElement.url != ''){
if (event.srcElement.getAttribute("target")!=null)
window.open(event.srcElement.url,event.srcElement.getAttribute("target"))
else
window.location=event.srcElement.url
}
}
}

function GradientShow() //实现淡入的函数
{
ie5menu.filters.alpha.opacity+=intInterval
if (ie5menu.filters.alpha.opacity<100) setTimeout("GradientShow()",intDelay)
}

function GradientClose() //实现淡出的函数
{
ie5menu.filters.alpha.opacity-=intInterval
if (ie5menu.filters.alpha.opacity>0) {
setTimeout("GradientClose()",intDelay)
}
else {
ie5menu.style.visibility="hidden"
}
}

function ChangeBG() //改变菜单项的背景颜色,这里的两种颜色值可以改为你需要的
{
oEl=event.srcElement
if (oEl.style.background!="navy") {
oEl.style.background="navy"
}
else {
oEl.style.background="#cccccc"
}
}
// -->
</SCRIPT>

<style type=text/css>
.cMenu {
FILTER: alpha(opacity=0);BACKGROUND-COLOR: #D6D3CE;BORDER-BOTTOM: #666666 2px solid; BORDER-LEFT: #E4E4E4 2px solid; BORDER-RIGHT: #666666 2px solid; BORDER-TOP: #E4E4E4 2px solid; COLOR: #000000; CURSOR: default; FONT-SIZE: 9pt; color:#000000;FONT-WEIGHT: normal; LINE-HEIGHT: 20px; POSITION: absolute; VISIBILITY: hidden; WIDTH: 110px
}
.menuitems {
font-size:9pt;
MARGIN: 2px;
PADDING-BOTTOM: 0px;
PADDING-LEFT: 15px;
PADDING-RIGHT: 3px;
PADDING-TOP: 0px;
}
</style>

<META content="Microsoft FrontPage 4.0" name=GENERATOR>
</HEAD>
<BODY>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0>
</OBJECT>
<RIGHTCLICK><!--[if IE]>
<DIV class=cMenu id=ie5menu onclick=jumptoie5() onmouseout=lowlightie5()
onmouseover=highlightie5()>

<DIV class=menuitems url="javascript:click_obj(0)">后退</DIV>
<DIV class=menuitems url="javascript:click_obj(1)">前进</DIV>
<DIV class=menuhr><hr style="width:100%"></DIV>
<DIV class=menuitems url="javascript:click_obj(2)">刷新</DIV>
<DIV class=menuitems url="javascript:click_obj(3)">加入收藏夹</DIV>
<DIV class=menuitems url="javascript:click_obj(4)">查看源文件</DIV>
<DIV class=menuhr><hr style="width:100%"></DIV>
<DIV class=menuitems url="javascript:click_obj(5)">属性</DIV>

</DIV>
<![endif]-->

<SCRIPT language=JavaScript>
<!--
function click_obj(id){
switch(id){
case 0:
history.back()
break
case 1:
history.forward()
break
case 2:
window.location.reload()
break
case 3:
window.external.AddFavorite(location.href, document.title)
break
case 4:
window.location = "view-source:" + window.location.href
break
case 5:
document.all.WebBrowser.ExecWB(10,1)
break
}
}

if (document.all&&window.print){
ie5menu.className="cMenu"
document.oncontextmenu=showmenuie5
document.body.onclick=hidemenuie5
}
//-->
</SCRIPT>
</RIGHTCLICK>
</BODY></HTML>

5.ie用activex实现打印 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:03

ie用activex实现打印 我没有检测过版本,ie6下正常
<head>...</head>加入:
<SCRIPT LANGUAGE=javascript>
<!--
function setPrint()
{
WB.ExecWB(8,1);
}
function previewPrint()
{
WB.ExecWB(7,1)
}
//-->
</SCRIPT>

在<body>...</body>加入:
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WB width=0>
</OBJECT>
<INPUT type="button" value="Set" id=button1 name=button1 onclick="setPrint();">
<INPUT type="button" value="Preview" id=button2 name=button2 onclick="previewPrint();">

6.自动清除输入框中的空格 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:05

自动清除输入框中的空格

再<head>...</head>间加入
<SCRIPT LANGUAGE="JavaScript">
<!--//
function ignoreSpaces(string) {
var temp = "";
string = '' + string;
splitstring = string.split(" "); //双引号之间是个空格;
for(i = 0; i < splitstring.length; i++)
temp += splitstring[i];
return temp;
}
//-->
</script>

如下代码加入<body>区

<form method="post" action="...">
<input type=text size=25 onBlur="this.value=ignoreSpaces(this.value);" name="text">
<input type=submit value="Ok" name="button">
</form>

7.普通右键菜单 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:08

普通右键菜单
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style>
<!--
.skin0{
position:absolute;
width:200px;
border:2px solid black;
background-color:menu;
font-family:Verdana;
line-height:20px;
cursor:default;
visibility:hidden;
}
.skin1{
cursor: default;
font: menutext;
position: absolute;
width: 165px;
background-color: menu;
border: 1 solid buttonface;
visibility:hidden;
border: 2 outset buttonhighlight;
}
.menuitems{
padding-left:15px;
padding-right:10px;
}
-->
</style>
</HEAD>
<BODY>
<script language="JavaScript1.2">
//set the skin of the menu (0 or 1, with 1 rendering a default Windows menu like skin)
var menuskin=1
//set this variable to 1 if you wish the URLs of the highlighted menu to be displayed in the status bar
var display_url=0
function showmenuie5(){
//Find out how close the mouse is to the corner of the window
var rightedge=document.body.clientWidth-event.clientX
var bottomedge=document.body.clientHeight-event.clientY
//if the horizontal distance isn"t enough to accomodate the width of the context menu
if (rightedge<ie5menu.offsetWidth)
//move the horizontal position of the menu to the left by it"s width
ie5menu.style.left=document.body.scrollLeft+event.clientX-ie5menu.offsetWidth
else
//position the horizontal position of the menu where the mouse was clicked
ie5menu.style.left=document.body.scrollLeft+event.clientX
//same concept with the vertical position
if (bottomedge<ie5menu.offsetHeight)
ie5menu.style.top=document.body.scrollTop+event.clientY-ie5menu.offsetHeight
else
ie5menu.style.top=document.body.scrollTop+event.clientY
ie5menu.style.visibility="visible"
return false
}
function hidemenuie5(){
ie5menu.style.visibility="hidden"
}
function highlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
if (display_url==1)
window.status=event.srcElement.url
}
}
function lowlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="black"
window.status=""
}
}
function jumptoie5(){
if (event.srcElement.className=="menuitems"){
if (event.srcElement.getAttribute("target")!=null)
window.open(event.srcElement.url,event.srcElement.getAttribute("target"))
else
window.location=event.srcElement.url
}
}
</script>
<!--[if IE]>
<div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5()">
<div class="menuitems" url="http://www.chinabs.net">★中国BS网★</div>
<div class="menuitems" url="http://www.sohu.com" target="_blank">搜狐搜索引擎</div>
<div class="menuitems" url="http://www.fanso.com">化云坊Fanso</div>
<div class="menuitems" url="http://www.163.com">网易搜索引擎</div>
<div class="menuitems" url="http://www.chinafootball.com">中国足球新闻网</div>
<div class="menuitems" url="http://www.365fm.com">联想网站</div>
<![endif]-->
<script language="JavaScript1.2">
if (document.all&&window.print){
if (menuskin==0)
ie5menu.className="skin0"
else
ie5menu.className="skin1"
document.oncontextmenu=showmenuie5
document.body.onclick=hidemenuie5
}
</script>
</BODY>
</HTML>

8.超链接提交表单 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:10

超链接提交表单
<script LANGUAGE="JavaScript">
function checkvalue()
{
if(document.welcomeform.nickname.value=="")
{
alert("昵称不能为空!");
return(false);
}
if(document.welcomeform.password.value=="")
{
alert("密码不能为空!");
return(false);
}
document.welcomeform.submit();
return(true);
}
</script>

在<body>...</body>之间加入如下代码:
<form name="welcomeform" method="post" action="welcome.asp">
<a href="#" onclick="javascript:checkvalue();return false:">登录</a>
</form>

9.不允许缓存页面 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:13

不允许缓存页面
html方式
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
</HEAD>
不允许缓存页面
使用java提供的方法,在jsp或者servlet中都可以
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
%>

10.不准确的页面loging [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:15

不准确的页面loging
<script>
var text="正在载入文档";i=0;
function load() {
if (i<6) {
text+=".";
Waiting.innerText=text;
i++;}
else {text="正在载入文档";i=0;}}
timer=window.setInterval("load()",300);
</script>

11.页面禁止刷新完全 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:18

页面禁止刷新完全
最好在pop出来的窗口里用,没工具栏的
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body onkeydown="KeyDown()" onbeforeunload="location=location"
oncontextmenu="event.returnValue=false">

<script language="Javascript"><!--
function KeyDown(){
if ((window.event.altKey)&&
((window.event.keyCode==37)||
(window.event.keyCode==39))){ alert("请访问我的主页");
event.returnValue=false;
}
if ((event.keyCode==8)|| (event.keyCode==116)){ //屏蔽 F5 刷新键
event.keyCode=0;
event.returnValue=false;
}
if ((event.ctrlKey)&&(event.keyCode==78)){ //屏蔽 Ctrl+n
event.returnValue=false;
}
if ((event.shiftKey)&&(event.keyCode==121)){ //屏蔽 shift+F10
event.returnValue=false;
}
}
</script>
</body>
</html>

12.一个显示ip和客户端所在地的包 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:20

一个显示ip和客户端所在地的包

2_9422_13.zip (160.88k)

13.唉,只好自己up [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:22

唉,只好自己up
两级联动菜单
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="JavaScript" type="text/javascript">
<!--
var province_ar=new Array("","学历文凭|旅游管理,工商企业管理,文秘,金融,国际贸易,会计,英语,计算机应用,法律,艺术设计","成人高教|工商企业管理,国际经济与贸易,外贸英语,计算机应用与管理,艺术设计","高教自考|饭店管理,工商企业管理,中英合作商务管理,保险,国际贸易,英语,电子商务,计算机及应用,法律,广告");

function show_province()
{
var pro_tmp=document.all.province;
for (m=pro_tmp.options.length-1;m>0;m--)
pro_tmp.options[m]=null;

for(i=0;i<province_ar.length;i++)
{
if(province_ar[i]!="")
{
tmp=province_ar[i].split("|");
pro_tmp.options[i]=new Option(tmp[0],tmp[0]);
}
}
}
function show_city(sc)
{
var temp=document.all.city;
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null;

if(province_ar[sc]!="")
{
tmp=province_ar[sc].split("|");
tmp=tmp[1];
tmp=tmp.split(",");
for(i=0;i<tmp.length;i++)
{
temp.options[i]=new Option(tmp[i],tmp[i]);
}
}
}
setTimeout("show_province();",20);//第一个搜索中省份城市对应
-->
</script>
</HEAD>

<BODY>
<FORM name="testform" id="testform">
<select id=province
onchange=show_city(this.options.selectedIndex)>
<OPTION value="" selected>请选择类别</option>
</select>
<select id=city>
<OPTION value="" selected>请选择专业</OPTION>
</select>
</FORM>
</BODY>
</HTML>

14.多级联动 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:23

多级联动
1.多级关联菜单(一)
<BODY>
<SELECT NAME="s1"><option>需要JavaScript才能正确显示</SELECT>
<SELECT NAME="s2"></SELECT>
<SELECT NAME="s3"></SELECT>
<SELECT NAME="s4"></SELECT>
<SCRIPT LANGUAGE="JavaScript">
<!--
//选择框的名字
selector = [ "s1", "s2", "s3", "s4" ];
//选择项: "名字", "值", 子选择
menu = [
"地球","1",
[
"中国","86",
[
"北京","BJ",
[
"--","1",null
],
"四川","SC",
[
"成都","28",null,
"乐山","",null,
"攀枝花","",null,
"自贡","",null,
"德阳","",null,
"绵阳","",null
]
],
"米国","1",
[
"加利福尼亚","CA",
[
"旧金山","1",null,
"洛杉矶","2",null
],
"华盛顿","WA",
[
"西雅图","seattle",null
]
]
],
"火星","2",
[
"大峡谷","86",
[
"小山丘","BJ",
[
"A地区","28",null,
"B地区","",null,
"C地区","",null
]
]
]
];

function wizz(level)
{
if( level == 0 )
a = menu;
else
{
str = "menu";
for( i=0; i<level; i++ )
str += "[" + (document.all[selector[i]].selectedIndex * 3 + 2) + "]";
a = eval(str);
}
if( a == null ) return;
s = document.all[selector[level]];
i = s.length;
while( i > 0 ) s.options[--i] = null;
while( i < Math.floor(a.length/3) )
s.options[i] = Option( a[i*3], a[i++*3+1] );
s.onchange = Function("wizz(" + (level+1) + ")");
wizz(level+1);
}
wizz(0);
//-->
</SCRIPT>
</BODY>
</HTML>

15.操作cookie [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:25

操作cookie
function getCookieVal (offset)
{
var endstr = documents.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = documents.cookie.length;
return unescape(documents.cookie.substring(offset, endstr));
}
function SetCookie (name, value)
{
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (2 < argc) ? argv[2] : null;
expires = new Date("December 31, 2023");
var path = (3 < argc) ? argv[3] : null;
var domain = (4 < argc) ? argv[4] : null;
var secure = (5 < argc) ? argv[5] : false;
documents.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = documents.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (documents.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = documents.cookie.indexOf(" ", i) + 1;
if (i == 0)
break;
}
return null;
}

function check_value()
{
uid=eval("window.document.myform.elements['fields[uid]']");
if (uid.value.Trim()=='')
{
alert("抱歉,用戶名不能為空!");
uid.focus();
return false;
}
pws=eval("window.document.myform.elements['fields[pws]']");
if (pws.value.Trim()=='')
{
alert("抱歉,密碼不能為空!");
pws.focus();
return false;
}

tz=eval("window.document.myform.elements['fields[tz]']");
if (tz.value.Trim()=='')
{
alert("抱歉,請選擇要登錄的套帳!");
uid.focus();
return false;
}
SetCookie ("uid",uid.value );
}

16.树型菜单 1 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:31

树型菜单 1
1 注意在相对目录下建立文件夹 photos 和三个文件open.gif list.gif fold.gif

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="error.jsp" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script language="JavaScript1.2">
<!--
/**
* Based on Folding Menu Tree
* Dynamic Drive (www.1studio.net)
* For full source code, installation instructions,
* 100's more DHTML scripts, and Terms Of
* Use, www.1studio.net
*
* Updated to support arbitrarily nested lists
* by 1studio@sina.com) 1studio 2001
*/

var head="photos/display:''"
img1=new Image()
img1.src="photos/fold.gif"
img2=new Image()
img2.src="photos/open.gif"
function change(){
if(!document.all)
return
if (event.srcElement.id=="foldheader") {
var srcIndex = event.srcElement.sourceIndex
var nested = document.all[srcIndex+1]
if (nested.style.display=="none") {
nested.style.display=''
event.srcElement.style.liststyleImage="url(photos/open.gif)"
}
else {
nested.style.display="none"
event.srcElement.style.liststyleImage="url(photos/fold.gif)"
}
}
}
document.onclick=change
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
var popup = null;
function inputorderid() {
popup = window.open('jspInputOrderid.jsp', '请输入订单编号','width=200,height=150,resizable=0,scrollbars=no');
}
function account() {
popup = window.open('jspAccountReceivable.jsp', '请选择客户名称','width=200,height=200,resizable=0,scrollbars=no');
}
function oppaccount(){
popup = window.open('jspOppAccount.jsp', '请选择机会类型','width=200,height=200,resizable=0,scrollbars=no');
}
function accountcust(){
popup = window.open('jspAccountCust.jsp', '请选择客户地域','width=262,height=150,resizable=0,scrollbars=no');
}
function OrderAccount(){
popup = window.open('jspAccountOrder.jsp', '请选择客户及订单有效日期范围','width=200,height=200,resizable=0,scrollbars=no');

}
//-->
</script>
<style type="text/css">

li {
font-family: "宋体", "新宋体";
font-size: 9pt;
line-height: 13pt;
margin-right: 5px;
cursor: hand;
}
#foldheader{
cursor:hand;
list-style-image:url(photos/fold.gif);
font-family: "宋体", "新宋体";
font-size: 10pt;
}
#foldinglist{
list-style-image:url(photos/list.gif);
font-family: "宋体", "新宋体";
font-size: 9pt;
}
BODY {
SCROLLBAR-FACE-COLOR: #6699CC;
SCROLLBAR-HIGHLIGHT-COLOR: #A6C4E1;
SCROLLBAR-SHADOW-COLOR: #A6C4E1;
SCROLLBAR-3DLIGHT-COLOR: #A6C4E1;
SCROLLBAR-ARROW-COLOR: #A6C4E1;
SCROLLBAR-TRACK-COLOR: #A6C4E1;
SCROLLBAR-DARKSHADOW-COLOR: #A6C4E1;
}

A { text-decoration:none; }
A:link { text-decoration:none; color: #000066; }
A:visited { text-decoration:none; color: #000033; }
A:hover {
text-decoration:underline;
color: #FF0000;
}
</style>
</head>
<body bgcolor="#CBDCED" leftmargin="3" topmargin="0">
<table width="100%" height="33" border="0" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" frame="void" align="left">
<tr>
<td>
<fieldset style="width:100%" align="left">
<legend><a href="" target="_blank"><font size="2"> JETCRM B/S2003 </font></a></legend>
<dl class="pt12normal">
<li id="foldheader"> 客户管理</li>
<ul id="foldinglist">
<li id="foldheader"> 客户管理</li>
<dl id="foldinglist" style="display:none">
<li><a href="customer_add.jsp" target="mainFrame"> 新建客户</a></li>
<li><a href="customer_query.jsp" target="mainFrame"> 客户查询</a></li>
<li><a href="menu.jsp#" onClick="accountcust()"> 客户统计</a></li>
</dl>
<li id="foldheader"> 联系人管理</li>
<dl id="foldinglist" style="display:none">
<li><a href="contact_add.jsp" target="mainFrame" class=black> 新建联系人</a></li>
<li><a href="contact_query.jsp" target="mainFrame" class=black> 联系人查询</a></li>
</dl>
<li id="foldheader"> 竞争对手管理</li>
<dl id="foldinglist" style="display:none">
<li><a href="adversary_add.jsp" target="mainFrame" class=black> 新建竞争对手</a></li>
<li><a href="adversary_query.jsp" target="mainFrame" class=black> 竞争对手查询</a></li>
</dl>
</ul>
<li id="foldheader">服务管理</li>
<ul id="foldinglist" style="display:none">
<li id="foldheader">联系历史</li>
<dl id="foldinglist" style="display:none">
<li><a href="ContactHistory_add.jsp" target="mainFrame" class=black>新建联系记录</a></li>
<li><a href="ContactHistory_list.jsp" target="mainFrame" class="balck">浏览联系记录</a></li>
</dl>
<li> 邮件发送</li>
<li id="foldheader">服务请求记录</li>
<dl id="foldinglist" style="display:none">
<li><a href="jsprequester_add.jsp" target="mainFrame" class=black>新建服务请求</a></li>
<li><a href="showRequesterlist.jsp" target="mainFrame" class="balck">服务请求浏览</a></li>
</dl>
<li id="foldheader">客户投诉</li>
<dl id="foldinglist" style="display:none">
<li><a href="jspFeedback_add.jsp" target="mainFrame">新建投诉记录</a></li>
<li><a href="feedback_list.jsp" target="mainFrame">投诉查询</a></li>
<li>投诉统计</li>
</dl>
</ul>
<li id="foldheader">销售管理</li>
<ul id="foldinglist">
<li id="foldheader"> 机会管理</li>
<dl id="foldinglist" style="display:none">
<li><a href="jspOppMan.jsp" target="mainFrame">新建机会</a></li>
<li><a href="jspOppQuery.jsp" target="mainFrame">机会查询</a></li>
<li><a href="menu.jsp#" onClick="oppaccount()">机会统计</a></li>
</dl>
<li id="foldheader">定单管理</li>
<dl id="foldinglist" style="display:none">
<li><a href="jspNewOrder.jsp" target="mainFrame">新建定单</a></li>
<li><a href="jspOrderQry.jsp" target="mainFrame">定单查询</a></li>
<li><a href="jspFufilOrder.jsp" target="mainFrame">订单履行</a></li>
<li><a href="jspFufilOrder.jsp" target="mainFrame">订单履行</a></li>
<li><a href="menu.jsp#" onClick="OrderAccount">订单额统计</a></li>
<li><a href="menu.jsp#" onClick=" inputorderid()">履行或结案</a></li>
<li><a href="menu.jsp#" onClick=" account()">应收款统计</a></li>
</dl>
<li id="foldheader">报价管理</li>
<dl id="foldinglist" style="display:none">
<li><a href="jspQuote_add.jsp" target="mainFrame">新建报价单</a></li>
<li><a href="jspQuote_list.jsp" target="mainFrame">浏览报价单</a></li>
</dl>
</ul>
<li id="foldheader">系统管理</li>
<ul id="foldinglist">
<li>权限管理</li>
<li><a href="jspBaseDataInsert.jsp" target="mainFrame">基础数据设置</a></li>
<li><a href="jspSetEmployee.jsp" target="mainFrame">员工管理</a></li>
<li><a href="jsppurview_set.jsp" target="mainFrame">权限设置</a></li>
</ul>
<li id="foldheader"><a href="#" target="mainFrame">重新登录</a></li>
</dl>
</fieldset>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>

17.JS计算的四舍五入笨方法~ [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:33

JS计算的四舍五入笨方法~
<script language="javascript">
document.write("value="+sle(2300.365));
function sle(aa){
var va=""+aa;
var newvalue="";
var newfloat=0;
var newfloat2=0;
var len=va.lastIndexOf(".");
if(len<0){
newvalue=""+aa;
}
else if(len==(va.length-2)){
newvalue=""+aa+"0";
}
else if(len==(va.length-3)){
newvalue=""+aa;
}
else{
newfloat=Math.round(eval(aa*100),2);
newfloat2=newfloat/100;
newvalue=""+newfloat2;
}
return newvalue;
}
</script>

18.在文本域中,直接用Ctrl+Enter提交表单的功能 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:36

在文本域中,直接用Ctrl+Enter提交表单的功能
<script language=javascript type="text/javascript">
function ctlent(eventobject)
{
if(event.ctrlKey && window.event.keyCode==13)
{
this.document.form1.submit();
}
}
</script>

19.全選复選框 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:37

/*全選复選框
startnum 開始值
endnum 結束值
formname 表單名
actionname 控件名
*/
function select_all(startnum,endnum,formname,actionname)
{
if (formname=='' || formname==null)
{
formname='forms[0]';
}
for (couter=startnum;couter<endnum;couter++)
{
action_key=eval("window.document."+formname+".elements['"+actionname+"["+couter+"]']");
action_key.checked=true;
}
}
/*反全選复選框
startnum 開始值
endnum 結束值
formname 表單名
actionname 控件名
*/
function unselect_all(startnum,endnum,formname,actionname)
{
if (formname=='' || formname==null)
{
formname='forms[0]';
}
for (couter=startnum;couter<endnum;couter++)
{
action_key=eval("window.document."+formname+".elements['"+actionname+"["+couter+"]']");
action_key.checked=false;
}
}

20.javascript的日期选择器(一) [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:39

javascript的日期选择器(一)
想用的话美化一下,对应有图片
想更改显示格式注意修改
setDay()函数参数顺序即可

<HTML>
<HEAD>
<TITLE></TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<SCRIPT language=JavaScript1.2>

// 一个简单的测试是否IE浏览器的表达式
isIE = (document.all ? true : false);

// 得到IE中各元素真正的位移量,即使这个元素在一个表格中
function getIEPosX(elt) { return getIEPos(elt,"Left"); }
function getIEPosY(elt) { return getIEPos(elt,"Top"); }
function getIEPos(elt,which) {
iPos = 0
while (elt!=null) {
iPos += elt["offset" + which]
elt = elt.offsetParent
}
return iPos
}

function getXBrowserRef(eltname) {
return (isIE ? document.all[eltname].style : document.layers[eltname]);
}

function hideElement(eltname) { getXBrowserRef(eltname).visibility = 'hidden'; }

// 按不同的浏览器进行处理元件的位置
function moveBy(elt,deltaX,deltaY) {
if (isIE) {
elt.left = elt.pixelLeft + deltaX;
elt.top = elt.pixelTop + deltaY;
} else {
elt.left += deltaX;
elt.top += deltaY;
}
}

function toggleVisible(eltname) {
elt = getXBrowserRef(eltname);
if (elt.visibility == 'visible' || elt.visibility == 'show') {
elt.visibility = 'hidden';
} else {
fixPosition(eltname);
elt.visibility = 'visible';
}
}

function setPosition(elt,positionername,isPlacedUnder) {
positioner = null;
if (isIE) {
positioner = document.all[positionername];
elt.left = getIEPosX(positioner);
elt.top = getIEPosY(positioner);
} else {
positioner = document.images[positionername];
elt.left = positioner.x;
elt.top = positioner.y;
}
if (isPlacedUnder) { moveBy(elt,0,positioner.height); }
}

//——————————————————————————————————————

// 判断浏览器
isIE = (document.all ? true : false);

// 初始月份及各月份天数数组
var months = new Array("一 月", "二 月", "三 月", "四 月", "五 月", "六 月", "七 月",
"八 月", "九 月", "十 月", "十一月", "十二月");
var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,
30, 31, 30, 31);
var displayMonth = new Date().getMonth();
var displayYear = new Date().getFullYear();
var displayDivName;
var displayElement;

function getDays(month, year) {
//测试选择的年份是否是润年?
if (1 == month)
return ((0 == year % 4) && (0 != (year % 100))) ||
(0 == year % 400) ? 29 : 28;
else
return daysInMonth[month];
}

function getToday() {
// 得到今天的日期
this.now = new Date();
this.year = this.now.getFullYear();
this.month = this.now.getMonth();
this.day = this.now.getDate();
}

// 并显示今天这个月份的日历
today = new getToday();

function newCalendar(eltName,attachedElement) {
if (attachedElement) {
if (displayDivName && displayDivName != eltName) hideElement(displayDivName);
displayElement = attachedElement;
}
displayDivName = eltName;
today = new getToday();
var parseYear = parseInt(displayYear + '');
var newCal = new Date(parseYear,displayMonth,1);
var day = -1;
var startDayOfWeek = newCal.getDay();
if ((today.year == newCal.getFullYear()) &&
(today.month == newCal.getMonth()))
{
day = today.day;
}
var intDaysInMonth =
getDays(newCal.getMonth(), newCal.getFullYear());
var daysGrid = makeDaysGrid(startDayOfWeek,day,intDaysInMonth,newCal,eltName)
if (isIE) {
var elt = document.all[eltName];
elt.innerHTML = daysGrid;
} else {
var elt = document.layers[eltName].document;
elt.open();
elt.write(daysGrid);
elt.close();
}
}

function incMonth(delta,eltName) {
displayMonth += delta;
if (displayMonth >= 12) {
displayMonth = 0;
incYear(1,eltName);
} else if (displayMonth <= -1) {
displayMonth = 11;
incYear(-1,eltName);
} else {
newCalendar(eltName);
}
}

function incYear(delta,eltName) {
displayYear = parseInt(displayYear + '') + delta;
newCalendar(eltName);
}

function makeDaysGrid(startDay,day,intDaysInMonth,newCal,eltName) {
var daysGrid;
var month = newCal.getMonth();
var year = newCal.getFullYear();
var isThisYear = (year == new Date().getFullYear());
var isThisMonth = (day > -1)
daysGrid = '<table border=1 cellspacing=0 cellpadding=2><tr><td bgcolor=#ffffff nowrap>';
daysGrid += '<font face="courier new, courier" size=2>';
daysGrid += '<a href="javascript:hideElement(\'' + eltName + '\')">x</a>';
daysGrid += ' ';
daysGrid += '<a href="javascript:incMonth(-1,\'' + eltName + '\')">? </a>';

daysGrid += '<b>';
if (isThisMonth) { daysGrid += '<font color=red>' + months[month] + '</font>'; }
else { daysGrid += months[month]; }
daysGrid += '</b>';

daysGrid += '<a href="javascript:incMonth(1,\'' + eltName + '\')"> ?</a>';
daysGrid += ' ';
daysGrid += '<a href="javascript:incYear(-1,\'' + eltName + '\')">? </a>';

daysGrid += '<b>';
if (isThisYear) { daysGrid += '<font color=red>' + year + '</font>'; }
else { daysGrid += ''+year; }
daysGrid += '</b>';

daysGrid += '<a href="javascript:incYear(1,\'' + eltName + '\')"> ?</a><br>';
daysGrid += ' Su Mo Tu We Th Fr Sa <br> ';
var dayOfMonthOfFirstSunday = (7 - startDay + 1);
for (var intWeek = 0; intWeek < 6; intWeek++) {
var dayOfMonth;
for (var intDay = 0; intDay < 7; intDay++) {
dayOfMonth = (intWeek * 7) + intDay + dayOfMonthOfFirstSunday - 7;
if (dayOfMonth <= 0) {
daysGrid += " ";
} else if (dayOfMonth <= intDaysInMonth) {
var color = "blue";
if (day > 0 && day == dayOfMonth) color="red";
daysGrid += '<a href="javascript:setDay(';
daysGrid += dayOfMonth + ',\'' + eltName + '\')" '
daysGrid += 'style="color:' + color + '">';
var dayString = dayOfMonth + "</a> ";
if (dayString.length == 6) dayString = '0' + dayString;
daysGrid += dayString;
}
}
if (dayOfMonth < intDaysInMonth) daysGrid += "<br> ";
}
return daysGrid + "</td></tr></table>";
}

function setDay(day,eltName) {
displayElement.value = (displayMonth + 1) + "/" + day + "/" + displayYear;
hideElement(eltName);
}

//——————————————————————————————————————

<!--
// fixPosition() 这个函数和前面所讲的那个函数一样
//
function fixPosition(eltname) {
elt = getXBrowserRef(eltname);
positionerImgName = eltname + 'Pos';
// hint: try setting isPlacedUnder to false
isPlacedUnder = false;
if (isPlacedUnder) {
setPosition(elt,positionerImgName,true);
} else {
setPosition(elt,positionerImgName)
}
}

function toggleDatePicker(eltName,formElt) {
var x = formElt.indexOf('.');
var formName = formElt.substring(0,x);
var formEltName = formElt.substring(x+1);
newCalendar(eltName,document.forms[formName].elements[formEltName]);
toggleVisible(eltName);
}

// fixPositions() 这个函数前面也讲过
function fixPositions()
{
fixPosition('daysOfMonth');
fixPosition('daysOfMonth2');
}

// -->
</SCRIPT>

<META content="MSHTML 5.00.2920.0" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff onresize=fixPositions()>
<P>
点击图片试试
<FORM name=date>
<CENTER>
<TABLE border=1 width=225>
<TBODY>
<TR>
<TD width=89>开始日期: </TD>
<TD width=120><INPUT name=ret size=10> <IMG align=absMiddle
alt="date picker" border=0 height=19 id=daysOfMonthPos name=daysOfMonthPos
onmouseup="toggleDatePicker('daysOfMonth','date.ret')"
src="pic1/alien.gif" width=19>
<DIV id=daysOfMonth style="POSITION: absolute"></DIV></TD></TR>
<TR>
<TD width=89>终止日期: </TD>
<TD width=120><INPUT name=ret2 size=10> <IMG align=absMiddle
alt="date picker" border=0 height=19 id=daysOfMonth2Pos
name=daysOfMonth2Pos
onmouseup="toggleDatePicker('daysOfMonth2','date.ret2')"
src="pic1/alien.gif" width=19>
<DIV id=daysOfMonth2
style="POSITION: absolute"></DIV></TD></TR></TBODY></TABLE></CENTER></FORM>
<P>
<SCRIPT language=JavaScript1.2>

function Cancel() {
hideElement("daysOfMonth");
}

</SCRIPT>

<SCRIPT language=JavaScript1.2>
<!--
hideElement('daysOfMonth');
hideElement('daysOfMonth2');
//-->
</SCRIPT>
</P></BODY></HTML>

21.一个表单,一个按钮,提交到两个页面 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:41

一个表单,一个按钮,提交到两个页面

1常规方法
<script>
function as(){
aa.action="a.asp"
aa.submit();
aa.action="b.asp"
aa.submit();
}
</script>

<form name=aa target="_blank">
....
<input type=button onclick=as()>
</form>

2 大牛方法,不实用
用xmlhttp提交
<script>
function aa(url)
{
a=new ActiveXObject("Microsoft.XMLHTTP")
a.open("POST",url,false);
a.setRequestHeader("content-type","application/x-www-form-urlencoded");
a.send("name=zhangsan")

}
</script>

22.判断是否输入了合法的日期 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:43

<!--//判断是否输入了合法的日期 (开始)//-->
function isTimeValid(year,month,day,hour){
if ((year == "") || (month == "") || (day ==""))
return 0;
varyearStr = new String(year);
varmonthStr = new String(month);
vardayStr = new String(day);
varhourStr = new String(hour);
varintYear,intMonth,intDay,intHour;
if(isNaN(year) || isNaN(month) || isNaN(day) || isNaN(hour))
return 0;
intYear = parseInt(year,10);
intMonth = parseInt(month,10);
intDay = parseInt(day,10);
intHour = parseInt(hour,10);

if(isNaN(intYear) || isNaN(intMonth) || isNaN(intDay) || isNaN(intHour))
return 0;

if(yearStr.length != 4)
return 0;
if(intYear < 1800)
return 0;
if((monthStr.length > 2) || (dayStr.length > 2) ||( hourStr.length > 2))
return 0;
if((intMonth > 12) || (intMonth < 1))
return 0;
if(intDay > maxMonthDay(intYear,intMonth) || intDay < 1) {
return 0;
}
if((intHour > 24) || (intHour < 0))
return 0;

return 1;
}

function isLeapYear(year){
if ((year%4 == 0 && year%100 != 0) || (year%400 == 0))
return 1;
else
return 0;
}

23.怎么判断是否是字符 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:46

怎么判断是否是字符
if (/[^\x00-\xff]/g.test(s)) alert("含有汉字");
else alert("全是字符");

24.没有任何边框 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:48

没有任何边框
<body onload=window.open('http://www.163.com','','fullscreen')>

25.手机号码检查 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:50

手机号码检查
<script>
function aa(obj)
{
if(obj.length!=11) alert("not");
else if(obj.substring(0,2)!="13") alert("not");
else if(isNaN(obj)) alert("not");
else alert("right");
}
</script>
<form name=codeN>
<input type=text name=No ><input type=button value='click' onclick=aa(document.codeN.No.value)>
</form>

26.用浏览器的打印功能 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:52

用浏览器的打印功能了。

<script language="Javascript">
var VERSION = parseInt(navigator.appVersion);
if (VERSION > 3)
{
document.write('<form><input type=button value="打印本页" name="Print" onClick="print()"></form>');
}
</script>
让JSP页面过期
response.addHeader("Cache-Control", "no-cache");
response.addHeader("Expires", "Thu, 01 Jan 1970 00:00:01 GMT");

27.不准粘贴 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:53

onpaste="return false" 不准粘贴

28.彻底屏蔽鼠标右键 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:55

oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键
<table border oncontextmenu=return(false)><td>no</table> 可用于Table

29.象QQ一样的自动伸缩菜单 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:57

象QQ一样的自动伸缩菜单

<table border=0 cellpadding=0 cellspacing=0 width="100%" bgcolor="#6699CC">
<tr>
<td align="center"><font color="#FFFFFF">员工:系统管理员</font></td>
</tr>
</table>
<table style="cursor : hand" onClick="return chg_chnl("work");" border=0 cellpadding=0 cellspacing=0 width="100%" bgcolor="#BBBBBB">
<tr>
<td align="center"><font color="#FFFFFF"><nobr>工作目录</nobr></font></td>
<td align="center"><div id="div_work" class="jd">5</div></td>
</tr>
<tr>
<TD height=1 bgcolor="#EFEFEF" colspan=2><img src="" height=1 width=100 border=0></td>
</tr>
</table>
<div id="work" style="display : ">
<table border="0" cellpadding=1 cellspacing=1>
<!--tr>
<td align="center"><a href="customer_service/list.asp" target="main"><img src="images/customer_service.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="customer_service/list.asp" target="main"><nobr>客户服务</nobr></a></td>
</tr-->
<tr>
<td align="center"><a href="customer/list.asp" target="main"><img src="images/customer.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="customer/list.asp" target="main"><nobr>客户管理</nobr></a></td>
</tr>
<tr>
<td align="center"><a href="project/list.asp" target="main"><img src="images/project.jpg" width=25 height=25 width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="project/list.asp" target="main"><nobr>项目管理</nobr></a></td>
</tr>
<tr>
<td align="center"><a href="contract/list.asp" target="main"><img src="images/contract.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="contract/list.asp" target="main"><nobr>合同管理</nobr></a></td>
</tr>
<tr>
<td align="center"><a href="document/list.asp" target="main"><img src="images/document.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="document/list.asp" target="main"><nobr>文档管理</nobr></a></td>
</tr>
<tr>
<td align="center"><a href="employee/list.asp" target="main"><img src="images/employee.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="employee/list.asp" target="main"><nobr>人事管理</nobr></a></td>
</tr>
</table>
</div>
<table style="cursor : hand" onClick="return chg_chnl("myhome");" border=0 cellpadding=0 cellspacing=0 width="100%" bgcolor="#BBBBBB">
<tr>
<td align="center"><font color="#FFFFFF"><nobr>个人工具</nobr></font></td>
<td align="center"><div id="div_myhome" class="jd">6</div></td>
</tr>
<tr>
<TD height=1 bgcolor="#EFEFEF" colspan=2><img src="" height=1 width=100 border=0></td>
</tr>
</table>
<div id="myhome" style="display : none">
<table border="0" cellpadding=1 cellspacing=1>
<tr>
<td align="center"><a href="employee/msg.asp" target="main"><img src="images/msg.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="employee/msg.asp" target="main"><nobr>消息管理</nobr></a></td>
</tr>
<tr>
<td align="center"><a href="setup.asp" target="foot"><img src="images/personal.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="setup.asp" target="foot"><nobr>个性设置</nobr></a></td>
</tr>
<tr>
<td align="center"><a href="loginname.asp" target="foot"><img src="images/password.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="loginname.asp" target="foot"><nobr>修改用户名</nobr></a></td>
</tr>
<tr>
<td align="center"><a href="password.asp" target="foot"><img src="images/password.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="password.asp" target="foot"><nobr>修改密码</nobr></a></td>
</tr>
</table>
</div>
<table style="cursor : hand" onClick="return chg_chnl("system");" border=0 cellpadding=0 cellspacing=0 width="100%" bgcolor="#BBBBBB">
<tr>
<td align="center"><font color="#FFFFFF"><nobr>系统管理</nobr></font></td>
<td align="center"><div id="div_system" class="jd">6</div></td>
</tr>
<tr>
<TD height=1 bgcolor="#EFEFEF" colspan=2><img src="" height=1 width=100 border=0></td>
</tr>
</table>
<div id="system" style="display : none">
<table border="0" cellpadding=1 cellspacing=1>
<tr>
<td align="center"><a href="system/employee.asp" target="main"><img src="images/auth.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="system/employee.asp" target="main"><nobr>权限分配</nobr></a></td>
</tr>
<tr>
<td align="center"><a href="system/transfer_rec.asp" target="main"><img src="images/transfer.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="system/transfer_rec.asp" target="main"><nobr>工作移交</nobr></a></td>
</tr>
<tr>
<td align="center"><a href="system/branch.asp" target="main"><img src="images/branch.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="system/branch.asp" target="main"><nobr>分 公 司</nobr></a></td>
</tr>
<tr>
<td align="center"><a href="system/op_rec.asp" target="main"><img src="images/op_rec.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="system/op_rec.asp" target="main"><nobr>操作日志</nobr></a></td>
</tr>
<tr>
<td align="center"><a href="system/doc_type.asp" target="main"><img src="images/document.jpg" width=25 height=25 border="0"></a></td>
<td align="center"><a class="menuparent" href="system/doc_type.asp" target="main"><nobr>文档类型</nobr></a></td>
</tr>
</table>
</div>
<table style="cursor : hand" onClick="return chg_chnl("exit");" border=0 cellpadding=0 cellspacing=0 width="100%" bgcolor="#BBBBBB">
<tr>
<td align="center"><font color="#FFFFFF"><nobr>退出系统</nobr></font></td>
<td align="center"><div id="div_exit" class="jd">6</div></td>
</tr>
</table>
</center>
</body>
</html>
<script language="JavaScript" type="text/javascript">
function chg_chnl(chnl){
if(document.all){
work.style.display = "none"; div_work.innerHTML = "6";
system.style.display = "none"; div_system.innerHTML = "6";
myhome.style.display = "none"; div_myhome.innerHTML = "6";
switch(chnl){
case "work":
work.style.display = ""; div_work.innerHTML = "5"; break;
case "system":
system.style.display = ""; div_system.innerHTML = "5"; break;
case "myhome":
myhome.style.display = ""; div_myhome.innerHTML = "5"; break;
case "exit":
top.location.href = "exit.asp"; break;
default:
work.style.display = ""; break;
}
}
return false;
}
</script>

30.Option排序 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 14:58

Option排序

<html>
<head>
</head>
<script language="javascript">
function sortOp()
{
arg=new Array();
for(var i=0;i<document.forms[0].D1.options.length;i++)
{
arg[i]=new Option(document.forms[0].D1.options[i].text,document.forms[0].D1.options[i].value);
}
arg.sort(compareOp);
for(var i=0;i<arg.length;i++)
{
document.forms[0].D1.options[i].text=arg[i].text;
document.forms[0].D1.options[i].value=arg[i].value;

}
}
function compareOp(OpA,OpB)
{
if(OpA.value>OpB.value)
return 1;
else if(OpA.value<OpB.value)
return -1;
return 0;
}
</script>
<body>

<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="E:\Tools\_private\form_results.txt"
S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p><select size="1" name="D1">
<option value="CCC">CCC</option>
<option value="BBB">BBB</option>
<option value="AAA">AAA</option>
<option value="DDD">DDD</option>
<option value="FFF">FFF</option>
<option value="EEE">EEE</option>
</select><input type="button" value="Sort" name="B1" onclick="sortOp()"></p>
</form>

</body>

</html>

31.日期类型 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 15:02

function checkdate(textthis)
{
//2003-05-06检测日期类型
var date=textthis.value;
var re = /^\d{4}-\d{2}-\d{2}$/;
if(!re.test(date))
{
window.alert('请输入日期格式如: 2003-05-06:');
textthis.value='2003-05-06';
textthis.select();
}
}
检查日前格式
用法:<input type="text" name="textfield" onchange="checkdate(this)">

32.去掉字符串头尾空格 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 15:05

去掉字符串头尾空格
function trim(s)
{
return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}

33.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 15:24

虽然JS与J2EE相差很远,但在WEB开发时,客户端的应用确实离不开它

34.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: chengbd
Posted on: 2004-06-21 15:25

希望大家再能提供些常用的JS代码

35.Re:手机号码检查 [Re: chengbd] Copy to clipboard
Posted by: helloworld
Posted on: 2004-06-21 15:45

请"禁止在这个帖子中使用笑脸标记"

36.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: jiechu
Posted on: 2004-07-03 22:13

計算String 的長度(转自51js)
<input onblur="alert(value.replace(/[^\x00-\xff]/g,'**').length)">

37.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: irisjacky
Posted on: 2004-07-04 09:11

It is kind of painful to paste all trivial JS techniques here.

Following is the site I used whenever I need to use javascript, although I normally try to avoid JS as much as possible.

http://dynamicdrive.com/

It provides a search function for JS scripts. All scripts there include example and source code - quite handy.

38.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: l_walker
Posted on: 2004-07-05 10:35

回车切换输入框:

<script>
function EqualTab(a){
if (a == 13)//回车键 {
if (document.forms[0].username.value != "") {
document.forms[0].password.focus();
return false;
} else {
return false;
}
}
}
// -->
</SCRIPT>

<form method="post" action"">
<input type="text" name="username" maxlength="20"
onKeyDown="return EqualTab(event.keyCode);"/>
<input type="password" name="password" maxlength="16"/>
</form>

39.Re:不允许缓存页面 [Re: chengbd] Copy to clipboard
Posted by: hohaischooldays
Posted on: 2004-07-31 21:07

请教:不允许缓存页面 的好处都有哪些,什么时候使用最恰当?

40.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: laoli97
Posted on: 2004-08-02 12:27

不错,啊,继续!

41.请教:提供一个对表格内容进行保存的js [Re: chengbd] Copy to clipboard
Posted by: laoli97
Posted on: 2004-08-02 13:39

具体的要求是这样的:
表格中的数据,需要在一开始,备份在数组中,每次当用户改变一个数据时,都要将现有的数据与备份数据比较一下,发生变化后,添加到updatelist中去,每次增加和删除同样添加到addlist和deletlist。这里有个地方要判断,就是增加后又删除的行要分析出来。最后点击保存,将上面的list发送到后台数据库。

谢谢大家了!!!

42.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: 748kele
Posted on: 2004-08-02 15:20

Big Smile
可能 有 错误

43.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: gunrose
Posted on: 2004-08-02 20:13

为什么不使用代码模式呢?
text


这样大家看代码都方便了。如果有可能提供文件下载吧,便于搜集

44.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: mannajava
Posted on: 2004-08-26 12:28

好东西,帮你顶


program2000 2004-08-05 感谢分享
天涯海阁 2004-08-11 很好啊 顶一下
mm 2004-08-11 好东西,谢谢!
neverlose 2004-08-18 多谢 支持一下
aquila 2004-08-24 顶

45.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: sonny
Posted on: 2004-08-29 22:44

http://dynamicdrive.com/
这个网站的确不错。。
顶!

46.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: kevinlau
Posted on: 2004-09-02 14:45

禁止二次提交
<html>
<head>
<script>
var flag=0;
function init() {  
document.forms[0].onsubmit = onsubmitok ;
}

function onsubmitok(event) {
if (flag>0){
  alert("submit twice!");
  return false;
}
flag+=1;
}
</script>  
</head>
<body onLoad="init()">
</body>
</html>

47.Re:树型菜单 1 [Re: chengbd] Copy to clipboard
Posted by: ming500
Posted on: 2004-09-15 18:09

老哥,你真伟大。我服了,

48.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: littledeer1974
Posted on: 2005-03-09 09:32

我想可以整理一下,放到WIKI上去,不知道chengbd兄怎么想Smile

49.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: 孤独王子
Posted on: 2005-03-09 12:11

很好,顶

50.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: errorter
Posted on: 2005-03-13 22:35

不错,只是个别有问题! Oh My God

51.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: kongqz
Posted on: 2005-03-16 12:36

鼠标滑过,选中效果
onMouseOver="this.focus();"

禁止选中checkbox: <input type=checkbox disabled>

鼠标移入移出某行或者某列的效果:
onMouseMove="this.style.backgroundColor='#FFFFCC'"
onMouseOut="this.style.backgroundColor=''"

52.Re:web开发常用js功能,希望大家都来扩充,众人拾柴火焰高 [Re: chengbd] Copy to clipboard
Posted by: 面孔
Posted on: 2005-03-17 08:53

呵呵,我也来顶一把:
输入大量数据后进行汇总,并把汇总数据精确到小数点后两位再显示到界面。
function caculate(num)
{
document.getElementById("record").value=0;
var items=document.forms(0).elements;
for(i=0;i<document.forms(0).elements.length;i++){
if(itemsLight Bulb.type=="select-one"){//struts文本输入标签

document.getElementById("record").value=(parseFloat(document.getElementById("record").value)+parseFloat(itemsLight Bulb.value)).toFixed(2);
}
}
}


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923