webform 光棒效果,删除操作弹出确定取消窗口
鼠标移入onmouseover和鼠标移出onmouseout,代码里没大写我这也就不大写了。那首先,我们得获取Class
为tr_item里的所有东西,也就是项标签里的数据。然后呢,我们定义一个oldColor为空,一会用来记录原来的颜色。接着,我们用for循环
把两个事件给项标签里所有的东西都附上。
<%-- 光棒效果 --%> <script type="text/javascript"> window.onload = function () { var items = document.getElementsByClassName("t-body"); var oldColor = ""; for (var i = 0; i < items.length; i++) { items[i].onmouseover = function () { oldColor = this.style.backgroundColor; this.style.backgroundColor = "green"; }; items[i].onmouseout = function () { this.style.backgroundColor = oldColor; }; } }; </script>
用户点击删除按钮时,弹出一个确定框,如果用户点击“确定”执行删除操作,否则不执行
方法一:
<a href="javascript:if(confirm('确实要删除吗?'))location='Delete.aspx?un=<%#Eval("GoodsName")%>'">删除</a>
方法二:
JS代码:
1 function del() { 2 var msg = "您真的确定要删除吗? 请确认!"; 3 if (confirm(msg)==true){ 4 return true; 5 }else{ 6 return false; 7 } 8 }
html代码:
<a href="" onclick="javascript:return del();">删除</a>
方法三:
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>确认是否删除</title> 6 <script type="text/javascript"> 7 function del(){ 8 if(!confirm("确认要删除?")){ 9 window.event.returnValue = false; 10 } 11 } 12 </script> 13 </head> 14 <body> 15 <a href="http://www.baidu.com" onclick="return del()">删除</a> 16 </body> 17 </html>
方法四:
<script type="text/javascript" language="javascript"> <!-- function confirmAct() { if(confirm('确定要执行此操作吗?')) { return true; } return false; } //--> </script> <a href="operate.aspx?mod=user&act=delete&id=564" onclick="return confirmAct();">执行操作</a>