IE to Netscape event assistance needed

J

Jesse Wade

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
 
Y

Yvon Kephren

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
 
J

Jesse Wade

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

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?
 
T

Thomas 'PointedEars' Lahn

Jesse said:
<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?

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

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

No.


PointedEars
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top