query.html

    <head><title>query.html</title></head>
    <script src=../window.js></script>
    <script src=../examples.js></script>

    <body>

    <input value="Send Query" type=button onclick="submitAll()">

    <script>

    w = new win(50,50,700,400,"query window","querywindow.html")

    function submitAll() {
        s1.setVar("map_countries_class_color",
            Math.round(Math.random() * 255) + " "  +
            Math.round(Math.random() * 255) + " "  +
            Math.round(Math.random() * 255)
        )
        w.submit()
    }

    function displayMap(s) {
        var mapimg = w.contentWindow.document.getElementsByTagName("img")[0]
        var mapurl = s.getVar("img")
        mapimg.src = mapurl
    }

    function displayQuery(s) {
        var windowSpan = w.contentWindow.document.getElementsByTagName("span")[0]
        var extentSpan = w.contentWindow.document.getElementsByTagName("span")[1]
        var serverFrameBody =s.contentWindow.document.body
        windowSpan.innerHTML = serverFrameBody.innerHTML
        var tbl = s.contentWindow.document.getElementsByTagName("table")[0]
        minx = miny = Number.POSITIVE_INFINITY
        maxx = maxy = Number.NEGATIVE_INFINITY
        for (var i=0;i<tbl.rows.length;i++) {
            var r = tbl.rows[i].cells[1].innerHTML.split(" ")
            if (parseInt(r[0])<minx) minx = r[0]
            if (parseInt(r[1])<miny) miny = r[1]
            if (parseInt(r[2])>maxx) maxx = r[2]
            if (parseInt(r[3])>maxy) maxy = r[3]
        }
        extentSpan.innerHTML = "Returned extent: " + minx + "/" + miny + " - " + maxx + "/" + maxy

    }

    w.setExecOnResize(submitAll)

    s1 = w.addServerFrame()
    s1.setServerURL(MSURL)
    s1.setVar("map",MSMAP)
    s1.setVar("map_projection","proj=sinu,ellps=clrk66")
    s1.setVar("mapext","-20000000 -10000000 20000000 10000000")

    s2 = w.addServerFrame()
    s2.setServerURL(MSURL)
    s2.setVar("map",MSMAP)
    s2.setVar("mode","itemnquery")
    s2.setVar("qlayer","countries")
    s2.setVar("qitem","NAME")
    s2.setVar("qstring","/.*/")

    s3 = w.addServerFrame()
    s3.setExecOnReturn(displayMap)

    s4 = w.addServerFrame()
    s4.imgnr = 1
    s4.setExecOnReturn(displayQuery)

    s1.setTarget(s3)
    s2.setTarget(s4)
    </script>
    </body>