1.用户名密码不为空检查:

function btnsubmit_onclick() 

    var userid 
=  document.userInfoFormBean.userId.value; 
    var password 
=  document.userInfoFormBean.pwd.value; 
    
if (userid.indexOf( " ' " ) !=- 1 || password.indexOf( " ' " ) !=- 1 ) {
        alert(
" 用户名、密码中包含非法字符 " );
        
return   false ;
    }

    
if  (userid == ""   ||  password == ""  )  
    

        window.alert(
" 用户编码、密码不能为空! " );
        document.userInfoFormBean.userId.focus();
        document.userInfoFormBean.pwd.focus();
        
return   false ;
    }
 
    
else {                   
        document.userInfoFormBean.action
= " /mms/doLoginAction.do " ;
        
return   true ;
    }
 
}


2.显示今天日期:
  < script >
                            todayDate 
=   new  Date();
                            date 
=  todayDate.getDate();
                            month
=  todayDate.getMonth()  + 1 ;
                            year
=  todayDate.getYear();
                            document.write(
" 您好!  今天是 " )
                            document.write(
" &nbsp;&nbsp; " )
                            
if (navigator.appName  ==   " Netscape " )
                            
{
                                document.write(
1900 + year);
                                document.write(
" " );
                                document.write(month);
                                document.write(
" " );
                                document.write(date);
                                document.write(
" " );
                            }

                            
if (navigator.appVersion.indexOf( " MSIE " !=   - 1 )
                            
{
                            document.write(year);
                            document.write(
" " );
                            document.write(month);
                            document.write(
" " );
                            document.write(date);
                            document.write(
" " );
                            document.write(
" &nbsp;&nbsp; " )
                            }

                            
if  (todayDate.getDay()  ==   5 ) document.write( " 星期五 " )
                            
if  (todayDate.getDay()  ==   6 ) document.write( " 星期六 " )
                            
if  (todayDate.getDay()  ==   0 ) document.write( " 星期日 " )
                            
if  (todayDate.getDay()  ==   1 ) document.write( " 星期一 " )
                            
if  (todayDate.getDay()  ==   2 ) document.write( " 星期二 " )
                            
if  (todayDate.getDay()  ==   3 ) document.write( " 星期三 " )
                            
if  (todayDate.getDay()  ==   4 ) document.write( " 星期四 " )
                            
</ script >  

             下面是一路上有你兄弟那看到的咚咚,比我的好像更牛点

<span id="aa">当前时间</span><script>setInterval("aa.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);
</script> 

3.Html拥有JSP 的request.getParmerter("")功能(转自--一路有你)


HTML也可以通过JS来到得参数,函数如下(我将它保存到了一个数组里面):


//--------------------------------------------------------------------------
//Name: GetArgsFromHref
//
//Pupers: the function will get the parameters from the server
//
//Parameter:
//sHref---->>the current URL
//sArgName---->>the Array store the name of parameters which you want to get
//
//Return: Array to store the result
//
//Author: Jkallen
//----------------------------------------------------------------------------
function GetArgsFromHref(sHref, sArgName)
{
    var args  
= sHref.split("?");
    var p_Result 
= new Array();
    
    
if(args[0== sHref) 
    
{
         
return p_Result; 
    }
  
    var str 
= args[1];
    args 
= str.split("&");
    
for(var i = 0; i < args.length; i ++)
    
{
        str 
= args[i];
        var arg 
= str.split("=");
        
if(arg.length <= 1
            
continue;
        
if(sArgName != null)
        
{
            
for(var c1 = 0; c1 < sArgName.length; c1++)
            
{
                var tempValue 
= arg[0];
                
if( tempValue == sArgName[c1])
                    p_Result[tempValue] 
= arg[1];
            }
   
        }
//end if
     }
//end for
     
     
return p_Result;
 }
//end GetArgsFromHref


4.控制对象的显示和隐藏



 页面中的DIV:
       < DIV ID = " ds1 "  CLASS = " submenu "  STYLE = " display:none " >  
  
< BR >< A HREF = "url1 "  target = " _blank " > XXXX </ A >  
        
< br >
  
< BR >< A HREF = " url2 "  target = " _blank " > XXXX2 </ A >  
  
< BR >   
  
</ DIV >


控制DIV显示和隐藏的函数

<
SCRIPT >  
           var cm
= null
            document.onclick 
=   new  Function( " show(null) " )  
             function getPos(el,sProp)  
{var iPos  =   0  
                 while (el!=null)  
{iPos+=el["offset" + sProp] 
                             el 
= el.offsetParent}
 
                          return iPos}
  
function show(el,m)  
{ if  (m)  {m.style.display = '' ;  
                    m.style.pixelLeft 
=  getPos(el, " Left "
                    m.style.pixelTop 
=  getPos(el, " Top " +  el.offsetHeight}
  
            if ((m!=cm) && (cm)) 
                         cm.style.display
='none';
                          cm
=m;
}
 
  
          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
             }
 
当在页面里添加:
<td align="left" valign="top" ID="d1" onmouseover="show(this,ds1);"><img src="images/sheng_14.gif" name="Image107" width="151" height="24" border="0"></td>