Jump to content

The addEventListener Blues


MrFish
 Share

Recommended Posts

I'm making custom on-events in js. I've made a custom scrollbar for this band site (so I can customize what it looks like in all browsers) but I've got a minor problem in firefox and a major problem in IE (of course...).http://chameleonsoundscape.com/Firefox problem-The only problem I have in firefox is that the selectstart event should disable it from selecting text. It works fine in chrome but it's not working in firefox.

	addEventListener(document, "selectstart", checkDrag, false);

		function checkDrag(evt)	{		if(isDragging)		{				evt.preventDefault();			return false;		}		else			return true;	}

IE Problem-The functions I'm using to make event listeners should work for ie but NONE of the events are being created. I've got it so it will alert the object that was sent to it if it won't work so you can visit the page in ie to see that.

	addEventListener(document, "mousemove", mouseCoords, false);	addEventListener(document, "selectstart", checkDrag, false);	addEventListener(document, "mouseup", endDrag, false);

function addEventListener(object, eventType, listener, capturing){	if(object.addEventListener)	{		object.addEventListener(eventType, listener, capturing);	}	else if(object.attachObject)	{		object.attachObject("on" + eventType, listener);	}	else	{		alert(object);	}}

Link to comment
Share on other sites

The problem might first stem from trying to override the addEventListener() function. Try calling it addEvent() instead.Internet Explorer doesn't use attachObject, it uses attachEvent()."selectStart" isn't a proper event. Here's a list of possible events and the browsers they're compatible with: http://www.quirksmode.org/dom/events/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...