can you "inline" event handlers for objects in 1 script like in VBScript?

F

Fred

This seems awkward, isn't there a better way to place event handlers
in the rest of the code with the logic for everything else like you
can with VBScript?

<script language="javascript"
if (myvar == true " {
do something
}
lots more code here...

</script>

<script for="myActiveX" event="Onclick()" language="javascript">
code for this event
</script>

<script for="myTreeView" event="OnConnect()" language="javascript">
code for this event
</script>
....

In other words, can I put it all between one <script></script> tag?

Thanks,

Fred
 
L

Lasse Reichstein Nielsen

This seems awkward, isn't there a better way to place event handlers
in the rest of the code with the logic for everything else like you
can with VBScript?

I don't know what you can with VBScritp. Can you explain what you want
to achieve?
<script for="myActiveX" event="Onclick()" language="javascript">

This construction only works in IE.
In other words, can I put it all between one <script></script> tag?

Sure

<script type="text/javascript">
function myHandler1(event) {...}
function myHandler2(event) {...}
...
document.getElementById("myActiveX").onclick = myHandler1;
document.getElementById("myActiveX").onconnect = myHandler2;
/* don't know the onconnect evemt, must be IE specific too */
</script>

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top