Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 软件时空 > 软件相关 > 搜到的javascript的几个事件捕捉脚本,值得收藏
【标  题】:搜到的javascript的几个事件捕捉脚本,值得收藏
【关键字】:javascript
【来  源】:http://blog.chinaunix.net/article.php?articleId=60552&blogId=10697

搜到的javascript的几个事件捕捉脚本,值得收藏

Your Ad Here http://www.54bk.com/user1/5463/archives/2005/9916.html
复制过来备用,各取所需

<SCRIPT FOR=window EVENT=onload>
   RecordEvent("src="/window", event=" + window.event.type);
</SCRIPT>

<SCRIPT FOR=tdcComposers EVENT=ondatasetchanged>
   FillSortDropDownWithFields(cboSort, this.recordset);
   RecordEvent("src=" + event.srcElement.id + ", event=ondatasetchanged");
</SCRIPT>

<SCRIPT FOR=tdcComposers EVENT=ondatasetcomplete>
   RecordEvent("src=" + event.srcElement.id + ", event=ondatasetcomplete, reason=" + event.reason);

 // wire up the navigation scriptlet
 // by providing it with a reference to the DSO
 //scrNavBtns.DSO = this;
</SCRIPT>

</SCRIPT>

<SCRIPT FOR=tdcComposers EVENT=ondataavailable>
   RecordEvent();
</SCRIPT>

<SCRIPT FOR=tblComposers EVENT=onreadystatechange>
   RecordEvent("src=" + event.srcElement.id + ", event=" + event.type + ", readyState=" + this.readyState);
</SCRIPT>


<SCRIPT FOR=document EVENT=onbeforeupdate>
   // data consumer events will bubble to the document
   // alert(window.event.srcElement.value + ", " + tdcComposers.recordset.fields(window.event.srcElement.dataFld).value);

   RecordEvent();
</SCRIPT>

<SCRIPT FOR=document EVENT=onafterupdate>
   RecordEvent();
   g_fFieldsChanged = g_fFieldsChanged + 1
</SCRIPT>

<SCRIPT FOR=tdcComposers EVENT=onrowenter>
   RecordEvent();
</SCRIPT>

<SCRIPT FOR=tdcComposers EVENT=onrowexit>
   RecordEvent();
   if (txtBorn.value > txtDied.value)
   {
    alert("Birth date must be less than or equal to deceased dates");
    event.cancelBubble = true;
    event.returnValue = false;
   }
</SCRIPT>

<SCRIPT FOR=window EVENT=onbeforeunload>
   RecordEvent();
   if (g_fFieldsChanged > 0)
      event.returnValue = "Data has changed.";
</SCRIPT>

<SCRIPT FOR=document EVENT=onerrorupdate>
   RecordEvent();
</SCRIPT>

<SCRIPT FOR=txtBorn EVENT=onbeforeupdate>
    RecordEvent();
 dToday = new Date();
 fRet = ValidateDate(parseInt(this.value), 0, dToday.getFullYear());
 event.cancelBubble = true;
 return fRet;
</SCRIPT>

<SCRIPT FOR=txtDied EVENT=onbeforeupdate>
    RecordEvent();
 dToday = new Date();
 fRet = ValidateDate(parseInt(this.value), 0, dToday.getFullYear());
 event.cancelBubble = true;
 event.returnValue = fRet;
</SCRIPT>

<SCRIPT FOR=tdcComposers EVENT=oncellchange>
 RecordEvent();
</SCRIPT>

<SCRIPT FOR=tdcComposers EVENT=onrowsinserted>
   RecordEvent();
</Script>

<SCRIPT FOR=tdcComposers EVENT=onrowsdelete>
   RecordEvent();
</script>

<SCRIPT language="JavaScript">
// perform some basic validation on the date
function ValidateDate(nValue, nMin, nMax)
{
 return;

 if (isNaN(nValue))
 {
  alert("Year required");
  return false;
 }

 if (nValue < nMin || nValue > nMax)
 {
     alert("Invalid year");
  return false;
 }

 return true;
}

function RecordEvent(cEventStr)
{
 var fUseOtherWindow = false;
 if (RecordEvent.m_winEvents == null && fUseOtherWindow)
 {
  RecordEvent.m_winEvents = window.open('','','top=0,left=0,height=200,width=500');
  if (RecordEvent.m_winEvents == null)
  {
   return;
  }
  cContent = '<TEXTAREA ID=txtEvents STYLE="position:absolute;top:10;left:0;height=200;width:500" ID=txtEvents></TEXTAREA>';
  RecordEvent.m_winEvents.document.body.insertAdjacentHTML('beforeEnd', cContent);
 }

 if (cEventStr == null)
 {
  var oEvent = window.event;
  var cID = "unknown";
  var cEventType = "unknown";
  var cEventReason = "unknown";

  if (oEvent != null)
  {
   cEventType = oEvent.type;
   cEventReason = oEvent.reason;
   
   var oSrcElement = oEvent.srcElement;
   if (oSrcElement != null)
   {
    cID = oSrcElement.id;
   }
  }

  cEventStr = "src=" + cID + ", event=" + cEventType + ", reason=" + cEventReason;
 }

 if (fUseOtherWindow && RecordEvent.m_winEvents != null)
 {
  txtEvents2 = RecordEvent.m_winEvents.document.body.all('txtEvents');
  txtEvents2.value = txtEvents2.value + ' ' + cEventStr;
 }
 
 txtEvents.value = txtEvents.value + ' ' + cEventStr;

}

function ClearEventLog()
{
 txtEvents.value = "";
}

// Navigate through the ADO recordset provided by the DSO
function ADONavigate(oElement, oDSO)
{
    if (oDSO == null || oElement == null)
 {
       return;
 }

    // The value of the button indicates the direction to navigate
 cValue = oElement.value;
 if (cValue == "<<")
 {
  oDSO.recordset.MoveFirst();
 }
 else if (cValue == " < ")
 {
  oDSO.recordset.MovePrevious();
  if (oDSO.recordset.BOF)
  {
   oDSO.recordset.MoveFirst();
  }
 }
 else if (cValue == " > ")
 {
  oDSO.recordset.MoveNext();
  if (oDSO.recordset.EOF)
  {
   oDSO.recordset.MoveLast();
  }
 }
 else if (cValue == ">>")
 {
  oDSO.recordset.MoveLast();
 }
}

// Add the specified value/text to the dropdown list
function AddItemToDropDown(oDropDown, cValue, cText)
{
 oOption = document.createElement('OPTION');
 oOption.value = cValue;
 oOption.text = cText; 
 oDropDown.add(oOption);
}

// Fill the specified dropdown with the metadata from the specified ADO RecordSet
function FillSortDropDownWithFields(oDropDown, oRecordSet)
{
   // only do this once. leave it to the caller to clear the drop-down otherwise
   if (oDropDown.options.length > 0)
      return;

   AddItemToDropDown(oDropDown, "None", "None"); // default
   // add each of the columns in the data set to the drop-down
   for (i = 0; i < oRecordSet.fields.count; i++)
   {
       oField = oRecordSet.fields(i);
    AddItemToDropDown(oDropDown, oField.name, oField.name);
   }
   cboSort.selectedIndex = 0;
}

function AllowEdit()
{
   EnableEditing(true);
   cmdEdit.value = "Don't Edit";
   cmdEdit.onclick = DisableEdit;
   cmdInsert.disabled=false;
}

function DisableEdit()
{
   EnableEditing(false);
   cmdEdit.value = "Edit";
   cmdEdit.onclick = AllowEdit;
   cmdInsert.disabled=true;
}

function EnableEditing(fEnable)
{
   txtFirst.readOnly = !fEnable;
   txtLast.readOnly = !fEnable;
   txtBorn.readOnly = !fEnable;
   txtDied.readOnly = !fEnable;
   txtBio.readOnly = !fEnable;
   cboOrigin.disabled = !fEnable;
}
</SCRIPT>

<SCRIPT FOR=document EVENT=onclick>
    // If the event bubbling up to the document comes from an object
 // the id of which begins with "cmdNav", navigate through the recordset
 oElement = window.event.srcElement;
 if (oElement.id.substring(0,6) == "cmdNav")
 {
       ADONavigate(oElement, tdcComposers);
    }
</SCRIPT>

<SCRIPT FOR=cboOriginFilter EVENT=onchange>
    cValue = this.options[this.selectedIndex].value;
 tdcComposers.object.Filter = (cValue == 'All' ? '' : 'Origin=' + cValue);
 tdcComposers.Reset();
</SCRIPT>

<SCRIPT FOR=cboSort EVENT=onchange>
 cValue = this.options[this.selectedIndex].value;
 tdcComposers.object.Sort = (cValue == 'None' ? '' : cValue);
 tdcComposers.Reset();
</SCRIPT>

JTree的简单应用:【上一篇】
终于找到了基于c的rdf 库:【下一篇】
【相关文章】
  • 用JavaScript脚本将当地时间转换成其它时区
  • 面向对象的JavaScript
  • 以一个最简单的例子把OO的JavaScript说明白
  • javascript程序
  • 十分推荐,值得收藏!javascript技巧大全
  • Eval方法(执行Javascript字串命令)
  • Javascript: 关注JSVM
  • javascript验证给定的日期的合法性
  • Javascript的IE和Firefox兼容性汇编[zt]
  • 关于javascript中parseInt函数的一个所谓的bug
  • 【随机文章】
  • 另类商业模式助 Linux 挑战微软
  • KNOPPIX中文版 简介
  • 基于SET协议的电子商务安全机制分析
  • 深入研究Application和Session对象(包括global.asa)2
  • IBM IC35L009UWD210-0,MAG3182LC,MAN3184LMC,MAJ3182M
  • shorewall 企业防火墙的完美实现
  • 财务管理程序笔记NO.1
  • 全文检索简介
  • 原创:eclipse反编译插件Jadclipse介绍
  • 在Spring框架下获取Bean的方式总结(原创)
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.