IE to Netscape event assistance needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jesse Wade

    #1

    IE to Netscape event assistance needed

    Hello people. Does the world need another DHTML popup calendar?
    Probably not, but I'm writing one anyway. It's unique in that it
    allows drag selection of a range of dates. Works great on IE6 but I'm
    having some trouble with Netscape and events. In particular, the
    mousedown event doesn't work. The event fires, but I can't seem to
    get a handle on what html element was clicked. Any help would be
    appreciated.

    Here's the page:


    The javascript file is:

  • Yvon Kephren

    #2
    Re: IE to Netscape event assistance needed

    Well I like this script. Is it useful? I'm not too sure. Is it cool? Hell Yeah.

    So some help. Yes Mozilla/Netscape have a diffrent way of useing events.

    In IE there are object for event listing
    EXAMPLE" document.onmous edown "

    In Mozilla you must create an instance of that event to listen to it.
    EXAMPLE" document.captur eEvent(MOUSEDOW N) "

    So I think all you would need to do to fix this would be

    var IE = document.all ? true : false;
    if (!IE){document. captureEvent(MO USEDOWN);}

    Test if browser is IE, If Not add Event Listener

    Comment

    • Jesse Wade

      #3
      Re: IE to Netscape event assistance needed

      > Well I like this script. Is it useful? I'm not too sure. Is it cool?[color=blue]
      > Hell Yeah.[/color]

      Glad you like it. All of the cool calendars I've seen are too big at
      30-80kb. I wrote this one so that when compressed it'll be 8kb and
      since the object loads with the page, the calendar displays instantly.

      Back to the code though....

      <DIV id=dvCalendar
      onSelectStart=' return false;'
      onmousedown='CA L.MouseDown(thi s);'
      onmouseover='CA L.MouseOver(thi s);'
      onmouseup='CAL. MouseUp();'>
      </DIV>

      With my calendar DIV setup like the above I'm getting into the
      CAL.MouseDown method... The event is firing with or without your
      additional lines. The problem is "this" is not the thing that's
      clicked. How do I do the equivalent of window.event.sr cElement in
      Netscape?

      I think I need to take a different approach than my current one but
      I'm not sure the correct direction to go.

      In IE clicking on a day causes the event to bubble up to the DIV's
      event handler. In Netscape, i'm guessing "this" is just the DIV?

      Do I need to have individual onmousedown=... events on each TD?

      Comment

      • Jesse Wade

        #4
        Re: IE to Netscape event assistance needed

        anyone?

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: IE to Netscape event assistance needed

          Jesse Wade wrote:[color=blue]
          > <DIV id=dvCalendar
          > onSelectStart=' return false;'
          > onmousedown='CA L.MouseDown(thi s);'
          > onmouseover='CA L.MouseOver(thi s);'
          > onmouseup='CAL. MouseUp();'>
          > </DIV>
          >
          > With my calendar DIV setup like the above I'm getting into the
          > CAL.MouseDown method... The event is firing with or without your
          > additional lines. The problem is "this" is not the thing that's
          > clicked. How do I do the equivalent of window.event.sr cElement in
          > Netscape?[/color]

          function eventListener(e )
          {
          e = e || window.event;
          var tgt;
          if (e && (tgt = e.target || e.srcElement))
          {
          // ...
          }
          }

          <... eventhandler=". .. eventListener(e vent) ..." ...>
          [color=blue]
          > Do I need to have individual onmousedown=... events on each TD?[/color]

          No.


          PointedEars

          Comment

          Working...