ServerFrames

The simplest example, doesn't use windows at all. The page just creates an image (without source) and a submit-button. With JavaScript, two serverFrames are created. The first one, s1, gathers the CGI variables for MapServer and submits the request to the server when the button is clicked. It also sets the second serverFrame, s2, as the receiver of the results .

What are those results? Well, Mapserver sends back an HTML file, in this case , the same file we used in the preceding sections. There however, it was displayed directly in the window. Here it gets into the second serverFrame and cannot be seen. We can retrieve the values from the form variables with the "getVar()" method. One hidden variable is called"img". In the original template, its value is "[img]", but MapServer replaces this by the actual URL of the map image it produced. This URL can be used as the source for the on-screen image, and this is done in the onReturn function of the second iframe, "displayMap()".

We'll use this way of setting/getting variables a lot in the following sections. Remember that variables are set in one serverFrames, and read out from another. That is why in the window interface the returned variables are read out by the win method "getReturnedVar()". They really come from another place as the variables set by "win.setVar()".

As getting images from a WebServer is such a common practice, there is a shorter way. A serverFrame can also set an image directly as target. Of course, in that case the WebServer has to send back just a raw image, not an HTML page. In MapServer this can be accomplished by setting the CGI variable "mode" to "map". MapServer will not send back the template file, but just the raw map image. This is done in , for three images. Images can also be superimposed in the browser, as in . This is a kind of OpenGIS functionality, but then with full MapServer support to build map layers.