Windows Dev Center

Java Applet, IFRAME tag and MouseMove


  • 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">


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

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




    The source of the IFRAME:


    Code Snippet


    <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"; = clientX + 10 + "px";  = clientY + 10 + "px";

    v = document.createElement("div");               = "tooltip";        = "100px";       = "100px";     = "0px solid black"; = "Yellow";
    v.innerHTML        = "";   = "absolute";


    if (document.addEventListener) {
        document.addEventListener("mousemove", stuff, false);
    } else if (document.attachEvent) {
        document.attachEvent("onmousemove", stuff);




    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