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>