1

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>

1 Answer 1

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");
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

This is the correct answer and the accepted answer should be changed to this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.