Loading ...
Sorry, an error occurred while loading the content.

addListener in Safari

Expand Messages
  • Peter Michaux
    Hi, The following html document works in Firefox 1.5.0.2 but not in Safari 1.3.2. In safari the first argument to the addEvent call causes a type error. This
    Message 1 of 2 , Apr 22, 2006
    • 0 Attachment
      Hi,

      The following html document works in Firefox 1.5.0.2 but not in Safari
      1.3.2. In safari the first argument to the addEvent call causes a type
      error. This seems to make sense but Firefox can handle this problem.
      I'm curious why the first argument to the addEvent call is either
      correctly handled by firefox or safari and incorrectly by the other
      browser. Any ideas?

      Thanks,
      Peter


      <html>
      <head>
      <script src="javascripts/YAHOO.js" type="text/javascript"></script>
      <script src="javascripts/event.js" type="text/javascript"></script>
      </head>
      <body>

      <div id="my_div">My Div!</div>

      <div id="logger"></div>

      <script type="text/javascript">

      function Component(element){
      function Dummy(){};
      Dummy.prototype = element;
      this.element = new Dummy();
      YAHOO.util.Event.addListener(this.element, "mouseover",
      this.overHandler, this, true);
      }
      Component.prototype.overHandler = function(e){
      document.getElementById("logger").appendChild(document.createTextNode(new
      Date()+" over. "));
      };

      var c = new Component(document.getElementById("my_div"));

      c.element.style.background="red";

      </script>

      </body>
      </html>
    • Adam Moore
      Assigning an existing HTML element as the prototype of your custom object is an unusual construct that I would expect to fail. The fact it works in FF/Moz is
      Message 2 of 2 , Apr 24, 2006
      • 0 Attachment
        Assigning an existing HTML element as the prototype of your custom object is
        an unusual construct that I would expect to fail. The fact it works in
        FF/Moz is interesting, but it does fail in all of the other major browsers.
        In fact, it crashes Opera.

        -Adam

        On Sat, Apr 22, 2006 at 09:02:39PM -0700, Peter Michaux wrote:
        > Hi,
        >
        > The following html document works in Firefox 1.5.0.2 but not in Safari
        > 1.3.2. In safari the first argument to the addEvent call causes a type
        > error. This seems to make sense but Firefox can handle this problem.
        > I'm curious why the first argument to the addEvent call is either
        > correctly handled by firefox or safari and incorrectly by the other
        > browser. Any ideas?
        >
        > Thanks,
        > Peter
        >
        >
        > <html>
        > <head>
        > <script src="javascripts/YAHOO.js" type="text/javascript"></script>
        > <script src="javascripts/event.js" type="text/javascript"></script>
        > </head>
        > <body>
        >
        > <div id="my_div">My Div!</div>
        >
        > <div id="logger"></div>
        >
        > <script type="text/javascript">
        >
        > function Component(element){
        > function Dummy(){};
        > Dummy.prototype = element;
        > this.element = new Dummy();
        > YAHOO.util.Event.addListener(this.element, "mouseover",
        > this.overHandler, this, true);
        > }
        > Component.prototype.overHandler = function(e){
        > document.getElementById("logger").appendChild(document.createTextNode(new
        > Date()+" over. "));
        > };
        >
        > var c = new Component(document.getElementById("my_div"));
        >
        > c.element.style.background="red";
        >
        > </script>
        >
        > </body>
        > </html>
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >

        --
      Your message has been successfully submitted and would be delivered to recipients shortly.