【发布时间】:2012-05-26 07:51:18
【问题描述】:
HTML DOM 对象模型定义了一个Event 对象with a target property。
查看 MSDN,Microsoft 记录了 target property。他们还将 srcElement 记录为 Internet Explorer 早期版本中 target 的别名:
target 属性类似于 Windows Internet Explorer 8 及更早版本中的srcElement。
所以我在 Internet Explorer 中,位于 click 断点处:
<div class="day" onclick="divClick(this)">
function divClick(sender)
{
var divCell = sender;
在 F12 工具 控制台我可以请求全局 event 对象:
>> event
{
actionURL : "",
altKey : false,
altLeft : false,
behaviorCookie : 0,
behaviorPart : 0,
bookmarks : null,
boundElements : {...},
button : 0,
buttonID : 0,
cancelBubble : false
...
}
我可以要求 event.srcElement 对象:
>> event.srcElement
{
align : "",
noWrap : false,
dataFld : "",
dataFormatAs : "",
dataSrc : "",
currentStyle : {...},
runtimeStyle : {...},
accessKey : "",
className : "header",
contentEditable : "inherit"
...
}
但是event.target 是空的:
>> event.target
如果我观看event,则没有target 属性:
那么如何在 Internet Explorer(9(文档模式:IE9 标准(浏览器模式:IE9)))中访问 event 对象的 target 属性?
【问题讨论】:
-
您是否考虑过让 jQuery 之类的库为您完成繁琐的工作?
标签: html internet-explorer events internet-explorer-9 dom