下面是我的asp(HTML)代码
<a id="More_Info" onclick ="window.top.location.href ='More_Info.asp?ussl=H&Start=<%=nRecCount%>&RS=<%=RecordStart%>;'" href="#">
从我的javascript我的魔杖激活onclick ="window.top.location.href ='More_Info.asp?ussl=H&Start=<%=nRecCount%>&RS=<%=RecordStart%>;'"
onclick事件...
<script type="text/javascript" >
{
//here i wand to activate the click event
document.getElementById("More_Info").onclick // Something like this
}
</script>
答案 0 :(得分:8)
这是我为similar question编写的函数的简化版本。您可以在Mozilla Developer Center documentation中找到initMouseEvent
的参数列表,但您不需要更改任何内容。
function clickLink(link) {
if (document.createEvent) {
var event = document.createEvent("MouseEvents");
event.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0,
false, false, false, false,
0, null);
link.dispatchEvent(event);
}
else if (link.fireEvent) {
link.fireEvent("onclick");
}
}