none
Java Applet, IFRAME tag and MouseMove

    Question

  • In a page with a Java applet I also have an inline frame. The IFRAME's source is a page which uses JavaScript to display the mouse coordinates in a paragraph tag along with a floating DIV next to the mouse. This entire setup works as expected in Firefox 2 and 3 but has rather unusual results in Internet Explorer 7: the coordinates do not update as the mouse moves but only when the mouse leaves the IFRAME and the CPU utilization is abnormally high.

     

    The main page:

    Code Snippet

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" http://www.w3.org/TR/html4/loose.dtd>
    <html>
    <head>

    <body>

    <applet height=18 width=800 code="ap.class"></applet>

    <iframe src="trackMouse.html"></iframe>

    </body>

    </html>

     

    The source of the IFRAME:

     

    Code Snippet

    <html>
    <body>

    <p id="info"></p>

    <script type="text/javascript">
    function stuff(e) {
        if (!e) {
            e = event;
        }

        var clientX = (document.all) ? e.offsetX : e.layerX;
        var clientY = (document.all) ? e.offsetY : e.layerY;

        document.getElementById("info").innerHTML = "X = " + clientX + "<br>Y = " + clientY;

        var tooltip = document.getElementById("tooltip");

        tooltip.innerHTML  = clientX + " Miles";
        tooltip.style.left = clientX + 10 + "px";
        tooltip.style.top  = clientY + 10 + "px";
    }

    v = document.createElement("div");

    v.id               = "tooltip";
    v.style.top        = "100px";
    v.style.left       = "100px";
    v.style.border     = "0px solid black";
    v.style.background = "Yellow";
    v.innerHTML        = "";
    v.style.position   = "absolute";

    document.body.appendChild(v);


    if (document.addEventListener) {
        document.addEventListener("mousemove", stuff, false);
    } else if (document.attachEvent) {
        document.attachEvent("onmousemove", stuff);
    }
    </script>
    </body>
    </html>

     

     

     

    I cannot seem to find any reason why this code would not work in IE. I would suspect it may be related to Java applets and IFRAME tags. Any help would be greatly appreciated.

    Monday, June 23, 2008 3:47 PM