日期:2014-05-16 浏览次数:20367 次
<script language="javascript" type="text/javascript"> var oldRow = null; window.onload = function () { var tblId = "<%=GridView1.ClientID %>"; var tbl = $e(tblId); if (tbl != null) { for (var i = 1; i < tbl.rows.length; i++) { tbl.rows[i].onclick = new Function("clickRow(this)") } } } function clickRow(row) { var colorHighlt = "#b2edce"; //alert(row.rowIndex); if (oldRow != row) { if (oldRow != null) { oldRow.style.backgroundColor = ""; } row.style.backgroundColor = colorHighlt; } else { row.style.backgroundColor = (row.style.backgroundColor == "" ? "#b2edce" : ""); } oldRow = row; } function $e(id) { return document.getElementById(id); } </script> <script type="text/javascript" language="javascript"> function setData() { var xm1 = document.all['xm1']; var oScroll = document.all['oScroll']; oScroll.setAttribute('Top', xm1.scrollTop); oScroll.save('divScrollTop'); } function getData() { var xm1 = document.all['xm1']; var oScroll = document.all['oScroll']; oScroll.load('divScrollTop'); xm1.scrollTop = (oScroll.getAttribute('Top') == null) ? 0 : oScroll.getAttribute('Top'); } window.onload = getData; </script> <o:scroll id="oScroll" style="behavior:url('#default#userData');"></o:scroll>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> New Document </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> </head> <script type="text/javascript"> //LZ问题,其原因在于同一个件事(window.onload)绑定了两个事件,JS会使用后一个事件 //请看下面的代码: //请思考一下,btn被点击时,会运行那一个方法? function a(){ alert("this is first method"); } function b(){ alert("this is second method"); } function fn(){ var btn=document.getElementById("btn"); btn.onclick=a; btn.onclick=b; } //-------------------分隔线------------------------ /**如何处理一个件事两个方法? 答:其实使用件事监听器就可以了。 请看下面代码: */ function fn1(){ var btn2=document.getElementById("btn2"); if(document.attachEvent){//IE浏览器 btn2.attachEvent("onclick",a); btn2.attachEvent("onclick",b