View Full Version : Getting mouse events from DOM objects

09-02-2004, 11:41 PM
I've got an interesting problem to solve and I can't seem to find much about how to do what I would think would be a common thing...

I want to "grab" the coordinates in number of pixels from an object when the user clicks on it. It's easy to do this for simple things like DIVs or IMGs, but what I want to do is grab these coords from a video player -- QuickTime or Windows Media Player or Real or whatever. I tried the simple-minded approach first, with an object tag placing an instance of Windows Media Player in my HTML body, and tried this in a JavaScript block:


where "WinMedia" is the ID attribute of the object, and I stuck an onClick event handler in the object tag. That didn't work; mouseclicks continue to be treated as they are before I did anything -- Media Player detects them itslef and starts or stops the video. Next, I tried to get clever. I wrapped the Media Player object in a DIV tag and set captureEvents on the DIV and stuck an event handler in the DIV tag. Still no dice. If I put some padding on the DIV I get the events from the area around the media player instance... but when I mouseover the video itself, no dice. It's like the browser is just opening a hole in itself for the Media Player object and Media Player is obviously handling mouse events on its own.

I finally tried making another div absolutely positioned "over" the video and set the event handler on that, but the browser real estate where the player is just not being looked at by the browser any more.

Any ideas, anyone? I did some googling on this and cannot find any clear info from the various video player plugs about how you can handle mouse events and pass info to the browser...

09-03-2004, 06:59 PM
The player object model has to provide the events, and as far as I know, IE is the only browser capable of binding to those from script.
Check out the MSDN documentation about the object element, and research the SDK's for each media player (or dig through their type libs for info...).

09-11-2004, 12:28 AM
That's what I was afraid of. Thanks! I'll have to put my controls off to the side or above or below the video window, then... and/or capture keystrokes...