下面是我的asp(HTML)代码
<a id="More_Info" onclick ="window.top.location.href ='More_Info.asp?ussl=H&Start=<%=nRecCount%>&RS=<%=RecordStart%>;'" href="#">
Run Code Online (Sandbox Code Playgroud)
从我的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>
Run Code Online (Sandbox Code Playgroud)
这是我为类似问题编写的函数的简化版本.您可以initMouseEvent在Mozilla开发人员中心文档中找到参数列表,但不需要更改任何内容.
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");
}
}
Run Code Online (Sandbox Code Playgroud)