Hello,

Attempting to set the click for an element via JavaScript but having some trouble. The event is to be set when an aspx web page loads. However, it's executing the event on page load rather than when the element is actually clicked. Lastly, the click event is not working after the page is loaded. I've tried setting the event using both the addEventListener and click methods but to no avail. Here's a sample of the code:

Code:
<a class="HelpContext" title="Help" id="NonModalHelpContext" style="right:30px;">?</a>

'javascript function called from code-behind
ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "SetHelpContext", "setHelpContext('" & sPid & "');", True)

'JavaScript
function setHelpContext(sUrl) {
        var ctrl = window.parent.document.getElementById('NonModalHelpContext');
        ctrl.addEventListener("click", window.open("HelpPage.aspx?" + sUrl, "HelpPage", "width=500,height=300,toolbar=no,scrollbars=yes,resizable=no,dependent=yes", false), false);
    }

//window.parent.document.getElementById('NonModalHelpContext').onclick = window.open("HelpPage.aspx?" + sUrl, "HelpPage", "width=500,height=300,toolbar=no,scrollbars=yes,resizable=no,dependent=yes",false);return false;
Any help is appreciated.