js 混合提交方式(含有get和post)

今天做的一个小东西,虽然东西小,但是包含了post和get提交,且同时都含有参数。

同时用到了js的encodeURI()方法

代码如下,以作备忘

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <style type="text/css">
  .bannertxt {
 color: #666666;
 font-size: 12px;
 font-style: normal;
 font-family: Hei;
 text-decoration: none;
}
.redtxt {
 font-family: Arial, Helvetica, sans-serif;
 font-size: 12px;
 color: #CC0000;
 text-decoration: none;
 CURSOR:text;
 }
</style>

 <script>
 
 String.prototype.trim = function()
{
    // 用正则表达式将前后空格
    // 用空字符串替代。
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
 var searchUrl="http://10.1.180.81/hrinfo/?name=";
 function change(idname){
  var lists=document.getElementsByName("flag");
  if("person"==idname){
  // alert("load person");
   lists[0].className="redtxt";
   lists[1].className="bannertxt";
   lists[2].className="bannertxt";
   lists[3].className="bannertxt";
   searchUrl="http://10.1.180.81/hrinfo/?name=";
   document.getElementById("sj").style.cssText="padding-left:30px";
  }
  if("dcone"==idname){
   lists[0].className="bannertxt";
   lists[1].className="redtxt";
   lists[2].className="bannertxt";
   lists[3].className="bannertxt";
   searchUrl="http://10.1.120.181/ESSearchApplication/search.do?command=searchLink&q=";
   document.getElementById("sj").style.cssText="padding-left:110px";
  }
  if("km"==idname){
   lists[2].className="redtxt";
   lists[0].className="bannertxt";
   lists[1].className="bannertxt";
   lists[3].className="bannertxt";
   searchUrl="http://10.1.120.181:9080/DCSearch/search.action?key=";
   document.getElementById("sj").style.cssText="padding-left:165px";
  }

  if("info"==idname){
   lists[3].className="redtxt";
   lists[0].className="bannertxt";
   lists[1].className="bannertxt";
   lists[2].className="bannertxt";
   searchUrl="";
   document.getElementById("sj").style.cssText="padding-left:230px";
  }
 }
 function doSubmit(){
    var key=document.getElementById("search").value;
      key=key.trim();
   if(key.length<1){
    alert("您的输入无有效字符,请输入您要查询的条件!");
    return false;
   }else{
   if(searchUrl.length<1){
   alert("系统正在开发之中!");
    }else{
  var urls=searchUrl+key;
  window.open(encodeURI(urls));
  }
  }
 }
 function keyDown(){
   if(event.keyCode==13){
     doSubmit();
 }
}
</script>
 </HEAD>

 <BODY>
  <body>
 <table border="0" cellSpacing="0" cellPadding="0">
  <tr vAlign="bottom">
   <td class="bannertxt">
   <span class="redtxt" id="flag" style="CURSOR: pointer" onclick="change('person')">姓名/电话/部门</span> |<span id="flag" style="CURSOR: pointer" onclick="change('dcone')"> DCone </span>|<span id="flag" style="CURSOR: pointer" onclick="change('km')"> 知识中心 </span>|<span id="flag" style="CURSOR: pointer" onclick="change('info')"> 专栏信息</span>
   </td>
  </tr>
  <tr>
   <td>
    <span id="sj"style="padding-left:40px"><img src="/wps/dc_resource/person/images/gray_arrow.gif"/></span>
   </td>   
  </tr>
  <tr>
   <td><input id="search" size="52" type="text" name="search" onkeydown="keyDown()"/></td><td>&nbsp;<img src="/wps/dc_resource/person/images/search.gif" width="31" height="20"  style="CURSOR: pointer" onclick="doSubmit()"/></td>
  </tr>
 </table>
 </BODY>
</HTML>

 

你可能感兴趣的:(html,正则表达式,css,prototype)