IE to Netscape event assistance needed

Discussion in 'Javascript' started by Jesse Wade, Jun 16, 2004.

  1. Jesse Wade

    Jesse Wade Guest

    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:
    http://wave.prohosting.com/jzero/cal/test_calendar.html

    The javascript file is:
    http://wave.prohosting.com/jzero/cal/calendar.js
     
    Jesse Wade, Jun 16, 2004
    #1
    1. Advertisements

  2. Jesse Wade

    Yvon Kephren Guest

    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.onmousedown "

    In Mozilla you must create an instance of that event to listen to it.
    EXAMPLE" document.captureEvent(MOUSEDOWN) "

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

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

    Test if browser is IE, If Not add Event Listener
     
    Yvon Kephren, Jun 18, 2004
    #2
    1. Advertisements

  3. Jesse Wade

    Jesse Wade Guest

    Well I like this script. Is it useful? I'm not too sure. Is it cool?
    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='CAL.MouseDown(this);'
    onmouseover='CAL.MouseOver(this);'
    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.srcElement 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?
     
    Jesse Wade, Jun 19, 2004
    #3
  4. Jesse Wade

    Jesse Wade Guest

    anyone?
     
    Jesse Wade, Jun 21, 2004
    #4
  5. function eventListener(e)
    {
    e = e || window.event;
    var tgt;
    if (e && (tgt = e.target || e.srcElement))
    {
    // ...
    }
    }

    No.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jun 25, 2004
    #5
    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.