以下列出的是我的javascript函数。该功能在IE上正常工作,但由于包含了window.event部分,因此无法在Firefox上运行。这样做的方式可以在IE以外的其他浏览器中使用,即在函数头的参数列表中使用参数e(或其他未定义的参数)。如果已有其他参数,如何将该事件添加到参数中?下面列出的是从应用程序到函数的示例调用。再次感谢。需要将参数和事件信息传递到javascript函数
function entityclick(where) {
try {
var tempstring = new String(window.event.srcElement.id)
}
catch (oExp) {
var tempstring = new String("noclickyclicky")
}
tempstring = tempstring.substr(0, 3)
if (tempstring != "img") {
if (selectedentity != "") {
try {
document.getElementById('tbl' + selectedentity).style.backgroundColor = ""
}
catch (oExc) {
}
}
selectedentity = where.EntityID + where.EntityCat;
var EntityID = where.EntityID
var EntityCat = where.EntityCat
var ParentEntityID = where.ParentEntityID
var ParentEntityCat = where.ParentEntityCat
var projtype = 0
document.getElementById('tbl' + selectedentity).style.backgroundColor = "lightsteelblue"
//document.all('tbl'+selectedentity).className = "HighlightMe"
ifram = document.getElementById('detailframe')
if (0 == 0) {
if (EntityCat == 35)
ifram.src = "../teams/Viewteam.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat + "&taskgrptype=" + GLOBALTASKGRPTYPE;
else if (EntityCat == 26)
ifram.src = "../teams/Viewteam.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat + "&taskgrptype=" + GLOBALTASKGRPTYPE;
else if (EntityCat == 34)
ifram.src = "../teams/Viewteam.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat + "&taskgrptype=" + GLOBALTASKGRPTYPE;
else if (EntityCat == 10)
ifram.src = "../solutions/ViewSolution.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat + "&taskgrptype=" + GLOBALTASKGRPTYPE;
else if (EntityCat == 11)
ifram.src = "../observations/ViewObservation.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat;
else if (EntityCat == 12)
ifram.src = "../actions/ViewAction.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat;
else if (EntityCat == 13)
ifram.src = "../tasks/ViewTask.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat;
ifram.style.left = '27%'
ifram.style.display = 'block'
//detail.style.display = 'none'
ifram.style.zIndex = 5
}
}
}
这里是调用函数
entityclick(document.getElementById('tbl' + glbRefreshID + glbRefreshCAT))
编辑:entityclick也被称为在某些地方其他方式,如
entityclick(this)
或
entityclick(document.getElementById('tbl' + GlobalExplodeID + GlobalExplodeCat))
什么是“哪里”?您在示例中调用该函数的dom元素不应该具有像“EntityID”等属性。 – Bergi
其中只是看起来像传递给函数的任何东西的名称(this或其他字符串将由上面的document.getElementById示例)。 – njj56