CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  JavaScript

关于srcElement,fromElement,toElement函数的区别

楼主chinadrgon(zhouzhou)2003-11-03 00:22:06 在 Web 开发 / JavaScript 提问

在DHTML中上面三个函数的区别是什么,请清楚的告诉我!   谢谢 问题点数:20、回复次数:4Top

1 楼xuzuning(唠叨)回复于 2003-11-03 08:34:40 得分 10

首先这三个不是函数,是属性  
  srcElement   产生事件的节点(DHTML对象)  
  当当前事件有移动成分时,如onmouseover、onmouseout等  
  fromElement、toElement  
  表示移动事件的两个端点Top

2 楼zhfkiller(杀手)回复于 2003-11-03 08:34:50 得分 10

srcElement   Attribute   |   srcElement   Property  
   
  --------------------------------------------------------------------------------  
   
  Retrieves   the   object   that   fired   the   event.    
   
  Syntax  
   
  HTML   <   srcElement   =   oObject   ...   >      
  Scripting   event.srcElement   [   =   oObject   ]    
   
  Possible   Values  
   
  oObject   Object爐hat   specifies   the   event   that   fired.    
   
  The   property   is   read/write.   The   property   has   no   default   value.  
   
  Expressions   can   be   used   in   place   of   the   preceding   value(s),   as   of   Microsoft?Internet   Explorer   5.   For   more   information,   see   Dynamic   Properties.  
   
  Example  
   
  This   example   uses   the   srcElement   property   to   retrieve   the   parent   object,   if   needed,   create   the   text   range,   move   to   the   original   object,   and   select   the   first   word   in   the   object.  
   
  <SCRIPT   LANGUAGE="JScript">  
  function   selectWord()   {  
          var   oSource   =   window.event.srcElement   ;  
          if   (!oSource.isTextEdit)    
                  oSource   =   window.event.srcElement.parentTextEdit;  
          if   (oSource   !=   null)   {  
                  var   oTextRange   =   oSource.createTextRange();  
                  oTextRange.moveToElementText(window.event.srcElement);  
                  oTextRange.collapse();  
                  oTextRange.expand("word");  
                  oTextRange.select();  
          }  
  }  
  </SCRIPT>Top

3 楼zhfkiller(杀手)回复于 2003-11-03 08:35:38 得分 0

fromElement   Attribute   |   fromElement   Property  
   
  --------------------------------------------------------------------------------  
   
  Retrieves   the   object   the   mouse   pointer   is   exiting   during   the   onmouseover   and   onmouseout   events.    
   
  Syntax  
   
  HTML   <   fromElement   =   oObject   ...   >      
  Scripting   event.fromElement   [   =   oObject   ]    
   
  Possible   Values  
   
  oObject   Object   that   specifies   or   receives   the   previous   location   of   the   mouse   pointer.    
   
  The   property   is   read/write.   The   property   has   no   default   value.  
   
  Expressions   can   be   used   in   place   of   the   preceding   value(s),   as   of   Microsoft?Internet   Explorer   5.   For   more   information,   see   Dynamic   Properties.  
   
  Example  
   
  In   this   example,   the   alert   returns   "mouse   arrived"   when   the   mouse   pointer   moves   over   the   button.  
   
  <SCRIPT>  
  function   testMouse(oObject)   {  
  if(!oObject.contains(event.fromElement))   {  
  alert("mouse   arrived");  
  }  
  }  
  </SCRIPT>  
  :  
  <BUTTON   ID=oButton   onmouseover="testMouse(this)">Mouse   Over   This.</BUTTON>Top

4 楼zhfkiller(杀手)回复于 2003-11-03 08:35:59 得分 0

toElement   Attribute   |   toElement   Property  
   
  --------------------------------------------------------------------------------  
   
  Retrieves   a   reference   to   the   object   to   which   the   user   is   moving   the   mouse   pointer.  
   
  Syntax  
   
  HTML   <   toElement   =   oObject   ...   >      
  Scripting   event.toElement   [   =   oObject   ]    
   
  Possible   Values  
   
  oObject   Object爐hat   specifies   the   object   being   moved   to   by   the   mouse.    
   
  The   property   is   read/write.   The   property   has   no   default   value.  
   
  Expressions   can   be   used   in   place   of   the   preceding   value(s),   as   of   Microsoft?Internet   Explorer   5.   For   more   information,   see   Dynamic   Properties.  
   
  Example  
   
  This   example   uses   the   toElement   property   to   display   the   tagName   of   the   object   to   which   the   user   moves   the   mouse   pointer.  
   
  <SCRIPT>  
  function   fnGetTo(){  
        spanTo.innerHTML=window.event.toElement.tagName;  
  }  
   
  </SCRIPT>  
  :  
  <SPAN   onmouseout="fnGetTo()">  
        <P>Mouse   Over   This</P>  
        <P>toElement:   <SPAN   ID="spanTo"></SPAN></P>  
  </SPAN>  
  Top

相关问题

  • 函数
  • 函数
  • 函数?
  • 函数
  • 函数
  • 函数
  • 函数?
  • 函数
  • Delphi函数 --> CB函数(急)!!
  • 函数调用函数

关键词

  • 函数
  • internet
  • toelement
  • fromelement
  • mouse
  • srcelement
  • valuesoobject
  • oobject
  • property
  • preceding

得分解答快速导航

  • 帖主:chinadrgon
  • xuzuning
  • zhfkiller

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo