JS注意事项

window.location.href

 

window.location.href('url ' ); 只能在IE下执行

window.location.href = "url"; 在IE,FF,IE下都可以

 

jquery string to date

 var remindTime = "2008-04-02 10:08:44"; 
//因之前在数据库中的类型为2008-04-02 10:08:44,必须转化为2008/04/02 10:08:44格式才能实例化Date对象
      var  str=remindTime.toString();
       str =  str.replace(/-/g,"/");
       str =  str.replace("T"," "); 
   var oDate1 = new Date(str);
   alert(oDate1.getDate());

 

onclick事件传参问题

如果参数是非int型的,需加单引号,否则不识别

οnclick="forwardDomainValueUpdate('${tDomainValueVo.domainValue}')"

 

页面间传参

此方法适合所有场景包括thickbox

window.parent.test(123);

 

引入: thickBox js 

Java代码  

1. <script src="Upimg/jquery-1.1.3.1.pack.js" type="text/javascript"></script>  

2. <script src="Upimg/thickbox-compressed.js" type="text/javascript"></script>  

3.   

4. 然后 在你需要 打开子窗口的地方 加入 class ="thickbox"  

5.   

6.   

7. <a href="bb.jsp?TB_iframe=true&amp;height=250&amp;width=400" title="add a caption to title attribute / or leave blank" class="thickbox">例子1</a>  

8.   

9. 在父页面写入 js :如:  

10.  

11.  function check(id){  

12.    alert(id);  

13.}  



然在你打开的  bb.jsp页面有时事件调用: 

Java代码  

1. <script type="text/javascript">  

2.   function check(){      

3.     window.parent.check(1);  

4.   

5.      //这样就调用父窗口了!  

6.   }  

7. </script>  

8.   

9. <body>   

10.   <input type="text" name="txtB" id="txtB" οnclick="check();">   

11.  </body>  

 

 

针对thickbox还有另一种访问方式:

父窗体:parent; 
子窗体:opener;(window.opener.reload();) 
所以看这样行不: 

Javascript代码  

1. document.getElementById("txtA").value=window.opener.document.getElementById("txtB").value;  

 

 

 

table增加、删除、修改行

        <table width="100%" border="0"cellspacing="1" cellpadding="1">

              <tbody><tr>

                 

                <td class="popup-sub-title">投诉类型  </td>

                <td class="popup-sub-title">是否购买产品  </td>

                <td class="popup-sub-title">客服人  </td>

                <td class="popup-sub-title">投诉时间  </td>

                <td class="popup-sub-title">投诉状态  </td>

                <td class="popup-sub-title">处理时间  </td>

                <td class="sub-title">操作</td>

              </tr>

              <c:forEach var="vo"items="${page.result}" varStatus="status">

                    <tr>

                      <td>${vo.complaintType}</td>

                      <td>${vo.isBuy}</td>

                      <td>${vo.serviceUser}</td>

                      <td>${vo.complaintTime}</td>

                      <td>${vo.state}</td>

                      <td>${vo.dealTime}</td>

                      <td class="list-link-hover">   

                            <input type="button" onclick="forwardInfo(${vo.complaintId})"name="${vo.complaintId}" id="paramInfoButton"value="详情" class="allcontralno-btn" />

                            <a id="forwardInfo_a_${vo.complaintId}"href="${ctx}/custComplaint/forwardInfo.htm?complaintId=${vo.complaintId}&keepThis=true&TB_iframe=true&height=600&width=900"class="thickbox" style="display:none"></a>                                            

                            <input type="button" onclick="forwardUpdate(${vo.complaintId})"name="${vo.complaintId}" id="updateButton"value="修改" class="allcontralno-btn" />

                            <a id="forwardUpdate_a_${vo.complaintId}"href="${ctx}/custComplaint/forwardUpdate.htm?complaintId=${vo.complaintId}&keepThis=true&TB_iframe=true&height=600&width=900"class="thickbox" style="display:none"></a>                                            

                            <input type="button" onclick="forwardDelete(${vo.complaintId},$(this).parent().parent())"name="${vo.complaintId}" id="deleteButton"value="删除 " class="allcontralno-btn" />

                            <a id="forwardDelete_a_${vo.complaintId}"href="${ctx}/custComplaint/delete.htm?complaintId=${vo.complaintId}&keepThis=true&TB_iframe=true&height=500&width=600"class="thickbox" style="display:none"></a>                                            

                        </td>

                    </tr>

              </c:forEach>

           </tbody></table>

 

 

index.remove();即可删除一行

 

 

[html] view plaincopy

  1. <script language="javascript">   
  2. $(document).ready(function(){   
  3. $("#t2 input").blur(function(){   
  4. alert(....当前行第一个文本框的值);   
  5. });   
  6.   
  7. });   
  8.   
  9. </script>   
  10. <table width="100%" border="0" cellspacing="0" cellpadding="0" id="t2">   
  11.   <tr>   
  12.     <td>a</td>   
  13.     <td>aa</td>   
  14.     <td>aaa</td>   
  15.     <td>   
  16.       <input name="textfield" type="text" id="textfield" value="aaaa" />   
  17.     </td>   
  18.     <td><input name="textfield3" type="text" id="textfield3" value="aaaaa" /></td>   
  19.     <td><input name="textfield4" type="text" id="textfield4" value="aaaaaa" /></td>   
  20.   </tr>   
  21.   <tr>   
  22.     <td>b</td>   
  23.     <td>bb</td>   
  24.     <td>bbb</td>   
  25.     <td><input name="textfield2" type="text" id="textfield2" value="bbbb" /></td>   
  26.     <td><input name="textfield6" type="text" id="textfield6" value="bbbbb" /></td>   
  27.     <td><input name="textfield5" type="text" id="textfield5" value="bbbbbb" /></td>   
  28.   </tr>   
  29. </table>   
  30.   
  31.   
  32. 当鼠标从tr中的任意文本框中移出时,弹出当前行里的第一个文本框中的值   

[javascript]view plaincopy

  1. $(document).ready(function(){   
  2. $("#t2 input").mouseout(function(){   
  3. var trNode = $(this).parent().parent(); //获取input的“爷爷”--tr  
  4. var forthChildTdNode =  trNode.children().eq(3);//获取第四个td  
  5. var firstInput = forthChildTdNode.children(); //获取第一个input  
  6.    
  7. alert("test"+firstInput.val()); //测试,OK  
  8. });   
  9.    
  10. });   


$(this).find("td:first-child input").val()

 

$("a").click(function(){
$td = $(this).parentsUntil("tr").find("td:eq(1)");
$td.val(自己改吧);
});

function中传中文的问题

如果参数中有中文需要加'',否则JS识别不出来。οnclick="window.parent.setCust(${item.cust_id },'${item.cust_name }')"

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值