event.srcElement.id为空

document.oncontextmenu = function (event)
{
var event = event || window.event;     

var clickID = event.srcElement.id+"";

}

clickID 为空,

原因:html代码:    




获取到的为image,加上parentElement即为XE1

解决方法:var event = event || window.event;     
var obj = event.srcElement || event.target;
var clickID = obj.parentElement.id+"";


你可能感兴趣的:(event.srcElement.id为空)