DHTMLX Docs & Samples Explorer

### Position

Select Window |
Position (x, y) |

Source

    <link rel="stylesheet" type="text/css" href="../../codebase/dhtmlxwindows.css">
    <link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxwindows_dhx_skyblue.css">
    <script src="../../codebase/dhtmlxcommon.js"></script>
    <script src="../../codebase/dhtmlxwindows.js"></script>

    <script src="../../codebase/dhtmlxcontainer.js"></script>

    <div>
    <table>
        <tr>
            <td style="padding-right: 10px;">Select Window</td>
            <td>
                <select id="sel">
                    <option value="w1">dhtmlxWindow #1</option>
                    <option value="w2">dhtmlxWindow #2</option>
                    <option value="w3">dhtmlxWindow #3</option>
                </select>
            </td>
        </tr>
        <tr>
            <td style="padding-right: 10px;">Position (x, y)</td>
            <td><input id="win_x" type="text" style="width: 30px;" value="310"> <input id="win_y" type="text" style="width: 30px;" value="140"></td>
        </tr>
        <tr>
            <td colspan="2" align="center" style="padding-top: 10px; padding-bottom: 10px;"><input type="button" value="Update" onclick="updateCurrent();"> <input type="button" value="Show Current" onclick="showCurrent();"></td>
        </tr>
        <tr>
            <td colspan="2">
                <div id="res"></div>
            </td>
        </tr>
    </table>
    </div>
    <div id="winVP" style="position: relative; height: 500px; border: #cecece 1px solid; margin: 10px;"></div>
    <script>function doOnLoad() {
        dhxWins = new dhtmlXWindows();
        dhxWins.setImagePath("../../codebase/imgs/");
        dhxWins.enableAutoViewport(false);
        dhxWins.attachViewportTo("winVP");
        w1 = dhxWins.createWindow("w1", 20, 30, 320, 240);
        w1.setText("dhtmlxWindow #1");
        w1.button("close").disable();
        w2 = dhxWins.createWindow("w2", 50, 70, 320, 240);
        w2.setText("dhtmlxWindow #2");
        w2.button("close").disable();
        w3 = dhxWins.createWindow("w3", 80, 110, 320, 240);
        w3.setText("dhtmlxWindow #3");
        w3.button("close").disable();
    }
    function updateCurrent() {
        var sel = document.getElementById("sel");
        var id = sel.options[sel.selectedIndex].value;
        var w = Number(document.getElementById("win_x").value);
        var h = Number(document.getElementById("win_y").value);
        dhxWins.window(id).setPosition(w, h);
    }
    function showCurrent() {
        var sel = document.getElementById("sel");
        var id = sel.options[sel.selectedIndex].value;
        var w = sel.options[sel.selectedIndex].firstChild.nodeValue;
        var pos = dhxWins.window(id).getPosition();
        document.getElementById("res").innerHTML = w + " position is (" + pos[0] + ", " + pos[1] + ")";
    }</script>