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

Discussion in 'Javascript' started by Fred, Jul 18, 2003.

  1. Fred

    Fred Guest

    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 for="myActiveX" event="Onclick()" language="javascript">
    code for this event

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

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


    Fred, Jul 18, 2003
    1. Advertisements

  2. I don't know what you can with VBScritp. Can you explain what you want
    to achieve?
    This construction only works in IE.

    <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 */

    Lasse Reichstein Nielsen, Jul 18, 2003
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.