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
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&height=250&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页面有时事件调用:
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();)
所以看这样行不:
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
- <script language="javascript">
- $(document).ready(function(){
- $("#t2 input").blur(function(){
- alert(....当前行第一个文本框的值);
- });
- });
- </script>
- <table width="100%" border="0" cellspacing="0" cellpadding="0" id="t2">
- <tr>
- <td>a</td>
- <td>aa</td>
- <td>aaa</td>
- <td>
- <input name="textfield" type="text" id="textfield" value="aaaa" />
- </td>
- <td><input name="textfield3" type="text" id="textfield3" value="aaaaa" /></td>
- <td><input name="textfield4" type="text" id="textfield4" value="aaaaaa" /></td>
- </tr>
- <tr>
- <td>b</td>
- <td>bb</td>
- <td>bbb</td>
- <td><input name="textfield2" type="text" id="textfield2" value="bbbb" /></td>
- <td><input name="textfield6" type="text" id="textfield6" value="bbbbb" /></td>
- <td><input name="textfield5" type="text" id="textfield5" value="bbbbbb" /></td>
- </tr>
- </table>
- 当鼠标从tr中的任意文本框中移出时,弹出当前行里的第一个文本框中的值
[javascript]view plaincopy
- $(document).ready(function(){
- $("#t2 input").mouseout(function(){
- var trNode = $(this).parent().parent(); //获取input的“爷爷”--tr
- var forthChildTdNode = trNode.children().eq(3);//获取第四个td
- var firstInput = forthChildTdNode.children(); //获取第一个input
- alert("test"+firstInput.val()); //测试,OK
- });
- });
$(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 }')"