Jonathan 的个人资料Jon's Vista Gadgets Blog日志列表 工具 帮助

日志


5月9日

How to determine which side the Flyout opened on

If you need to determine which side your Flyout opened, relative to your Gadget, you need to compare window.screenLeft of the Gadget parent to the Flyout.  Nothing of course is that simple, as the Flyout screen position isn't determined until the Flyout has been composed.  The trick is to repeatedly check the Flyout's position until it has been defined.

Add this code to the HEAD section:

    var offScreen = window.screenLeft;
   
    function checkFlyout() {
        if (window.screenLeft == offScreen)
        {
            setTimeout(checkFlyout, 100);
            return;
        }
   
        if (window.screenLeft > parseInt(System.Gadget.document.parentWindow.screenLeft)) {
           document.body.innerHTML = "right";
        } else {
           document.body.innerHTML = "left";
        }
    }

and then add an onload event to the Flyout body:

onload="checkFlyout()"