最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - how to invoke click event from javascript? - Stack Overflow

programmeradmin7浏览0评论

Below is my asp(HTML) code

<a id="More_Info" onclick ="window.top.location.href ='More_Info.asp?ussl=H&Start=<%=nRecCount%>&RS=<%=RecordStart%>;'" href="#">

from my javascript i wand to activate the onclick ="window.top.location.href ='More_Info.asp?ussl=H&Start=<%=nRecCount%>&RS=<%=RecordStart%>;'" onclick event...

<script type="text/javascript" >
{
//here i wand to activate the click event 
document.getElementById("More_Info").onclick // Something  like this
}
</script>

Below is my asp(HTML) code

<a id="More_Info" onclick ="window.top.location.href ='More_Info.asp?ussl=H&Start=<%=nRecCount%>&RS=<%=RecordStart%>;'" href="#">

from my javascript i wand to activate the onclick ="window.top.location.href ='More_Info.asp?ussl=H&Start=<%=nRecCount%>&RS=<%=RecordStart%>;'" onclick event...

<script type="text/javascript" >
{
//here i wand to activate the click event 
document.getElementById("More_Info").onclick // Something  like this
}
</script>
Share Improve this question edited Mar 4, 2010 at 14:56 Pointy 414k62 gold badges595 silver badges629 bronze badges asked Mar 4, 2010 at 14:23 AlexAlex 1,9739 gold badges36 silver badges41 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

This is a simplified version of a function I wrote for a similar question. You can find a list of the arguments to initMouseEvent in the Mozilla Developer Center documentation but you shouldn't need to change anything.

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");
    }
}
发布评论

评论列表(0)

  1. 暂无评论