I'm seeing a few questions related to this on SO already, but I think mine is sufficiently different to not be considered a duplicate (if I'm wrong let me know).
I have an ActiveX control I've written in C# and while I have it mostly working, I want to raise an event in JavaScript when it's clicked (it displays an image so it's a visual element on the page).
The end goal of what I'm looking to accomplish is no different than if it were a <span>
tag and it had an onclick
event to raise a JavaScript function when the area of the tag were clicked.
Most of the stuff I've read on it goes into very fine detail on how to handle events in an ActiveX control and send info back/forth, and that's fine, but it seems overly complicated. I'm not looking to communicate with the ActiveX control, I just need a JavaScript function to fire off when I click it, in a way similar to a <span>
or <div>
tag. I can handle everything else in JavaScript. Simply wrapping the control in a <span>
or <div>
with an onclick
event has no effect - the ActiveX control pretty much overrides it.
Is there a simple way to handle this for an ActiveX control written in C#?
I guess another way of putting it is - I'm working with a third party control and we have to use code similar to the following to get it to communicate with our HTML page via JavaScript
<script type="text/javascript" event="OnMouseClick(index)" for="AXObjectName">
<!--
AXObjectName_OnMouseClick(index);
//-->
</script>
Where AXObjectName
is the name/id of the control and AXObjectName_OnMouseClick
is the name of the JavaScript function it will fire in my code, passing an index
parameter. However, what all do I have to do to set up a method like OnMouseClick
in the control? And if I don't want to pass any actual information (i.e., no index
) do I even have to go this far?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…