Catch mouse specific events -- is it not possible?

Discussion in 'Javascript' started by Javier, Jul 20, 2003.

  1. Javier

    Javier Guest

    I have a java applet that is embedded into a html page and occupies
    almost the whole browser window. The applet is something like
    interactive, where users can write things and click on different
    buttons. One of these buttons is a stop, close one. Users can turn the
    applet off through clicking on that button. My problem now is that
    when the applet is turned off, the browser window, where the applet is
    embedded is still open. I want that the browser window is turned off
    at the same time as the applet.

    I thought I could write a javascript that captures mouse specific
    events such as the position and the clicks. That javascript should
    catch the clicks on the "turn-off-button" of the applet.

    The problem is that I am able to capture mouse movements, but it does
    not work when I try to catch mousedown-events. Below is the code of my
    html page. The javascript works fine when there is no applet.

    Remark: To solve this problem, it has to be done through javascript,
    since it is not possible to access any variables of the java applet.

    I would appreciate any hint.
    Thanks a lot.

    --------------------------------------------------------------------------------
    <html>
    <head>
    <script language="JavaScript">

    /*-------------- caputre mousedown events--------------- */

    if (document.layers) document.captureEvents(Event.MOUSEDOWN);
    if (document.layers || document.all) document.onmousedown =
    CaptureClick;
    if (document.addEventListener) document.addEventListener('mousedown',
    CaptureClick, true);

    function CaptureClick(eventObject){
    if (document.all){
    alert(xpos + ':' + ypos);
    }
    }

    /*------------capture mousmove events------------------*/
    if (document.layers) document.captureEvents(Event.MOUSEMOVE);
    if (document.layers || document.all) document.onmousemove =
    mouseMoveHandler;
    if (document.addEventListener) document.addEventListener('mousemove',
    mouseMoveHandler, true);

    function mouseMoveHandler (evt) {
    var xpos = document.all ? event.clientX : document.layers ? evt.x :
    evt.clientX;
    var ypos = document.all ? event.clientY : document.layers ? evt.y :
    evt.clientY;
    window.status =xpos + ':' + ypos;
    }
    </script>

    </head>

    <body >
    <APPLET NAME="" CODEBASE="" CODE="" HEIGHT="500" WIDTH="700"
    ALIGN="MIDDLE">
    ...
    ...
    </APPLET>
    </body>
    </html>
     
    Javier, Jul 20, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Black
    Replies:
    8
    Views:
    4,190
    Xenos
    Aug 20, 2004
  2. Replies:
    2
    Views:
    594
    Gernot Frisch
    Dec 15, 2005
  3. Adam
    Replies:
    9
    Views:
    586
    red floyd
    Feb 2, 2006
  4. Marteno Rodia

    catch doesn't catch a thrown exception

    Marteno Rodia, Aug 3, 2009, in forum: Java
    Replies:
    5
    Views:
    586
    Daniel Pitts
    Aug 5, 2009
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    393
    Chris
    Aug 30, 2005
Loading...

Share This Page