Web Analytics Made Easy -
StatCounter implicit event binding? - CodingForum

Announcement

Collapse
No announcement yet.

implicit event binding?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • implicit event binding?

    Can anyone tell me from what version of JScript this is supported?

    example:
    Code:
    <script type="text/JScript">
    
    function window&#58;&#58;onload(){
    alert("Hello!");
    }
    
    function window.onbeforeunload(){
    alert("Goodbye!");
    }
    </script>
    hmm... ?

  • #2
    I found the answer: Version 3.0

    ref: Scripting Events("Automagic" Support)
    hmm... ?

    Comment


    • #3
      Is there any special reason for using that syntax instead of the normal cross browser compatible
      Code:
      oElmRef.on[i]event[/i]=function(){
          /* Event handler body */
      };
      ?
      ?
      ?
      liorean <[[email protected]]>
      Articles: RegEx evolt wsabstract , Named Arguments
      Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
      Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

      Comment


      • #4
        Most useful for object event handling, probably.

        comparing this:
        <script for="object.id" event="click()">
        // do something
        </script>

        <script for="object.id" event="mousedown()">
        // do something
        </script>



        to this:
        <script>
        function object.id::click(){
        // do something
        }

        function object.id::mousedown(){
        // do something
        }
        </script>
        hmm... ?

        Comment


        • #5
          Yes, but what's the rationale behind using
          Code:
          <script type="text/jscript">
          function object::onclick(){
          // do something
          }
          
          function object.onmousedown(){
          // do something
          }
          </script>
          instead of
          Code:
          <script type="text/javascript">
          object.onclick=function(){
          // do something
          }
          
          object.onmousedown=function(){
          // do something
          }
          </script>
          The size difference is minimal, and the latter is supported by all browsers.
          liorean <[[email protected]]>
          Articles: RegEx evolt wsabstract , Named Arguments
          Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
          Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

          Comment


          • #6
            Originally posted by liorean
            The size difference is minimal, and the latter is supported by all browsers.
            That's right.

            Though, my rationale for using the implicit form is browser-specific, where automation is involved, and object.onevent=function() is not possible, such as:

            Code:
            <html>
            <head>
            <title>Microsoft Slider Control (5.0)</title>
            </head>
            <body style="text-align:center">
            
            <object id="sliderControl" 
            classid="clsid:373FF7F0-EB8B-11CD-8820-08002B2F4F5A">
            </object>
            <br><br>
            <textarea id="oEvent" cols="20" rows="30">
            </textarea>
            
            <script type="text/JScript">
            
            function sliderControl::click(){
            oEvent.value += "click" + "\n";
            }
            function sliderControl::keydown(){
            oEvent.value += "keydown" + "\n";
            }
            function sliderControl::keypress(){
            oEvent.value += "keypress" + "\n";
            }
            function sliderControl::keyup(){
            oEvent.value += "keyup" + "\n";
            }
            function sliderControl::mousedown(){
            oEvent.value += "mousedown" + "\n";
            }
            function sliderControl::mouseup(){
            oEvent.value += "mouseup" + "\n";
            }
            function sliderControl::scroll(){
            oEvent.value += "scroll" + "\n";
            }
            function sliderControl::change(){
            oEvent.value += "change" + "\n";
            }
            </script>
            </body>
            </html>
            it just seems better not to have a new script block for each event...
            hmm... ?

            Comment


            • #7
              Yeah I've seen that syntax before with the MS Speech API - events which are internal to the API and can't otherwise be captured, are often exposed like that.
              "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

              Comment


              • #8
                Yeah,but u can do this:
                object:nclick(){
                ...
                }

                In a <script> block only AFTER the object has been written in HTML,am I not correct??

                Comment


                • #9
                  Obviously, a non-existent object cannot be referenced...
                  hmm... ?

                  Comment


                  • #10
                    Exactly why some code has to be put in the window.onLoad event handler.

                    Comment

                    Working...
                    X