Naming Elements

Until now we have used "setVar()" and "getVar()" to get at the contents of windows and serverFrames. These are however just shortcuts to the full addressing offered by the . Every HTML element in a Web page is scriptable; you just have to know the naming hierarchy. The uppermost element, from which all others are derived, is the window. This is not a MapClient window (these are called "win"), but the all-compassing container for everything that is in the page. has quite a few properties and methods, the most important of which is . Every element in the document can be accessed by three methods: In Mapclient, this concept is extended to serverFrames and win objects. These are just decorated iframes, and an iframe has the same structure as a regular HTML page. The starting point for a serverFrame or win is "contentWindow". So, given a declaration of:
w = new win(10,10,100,100,"my window","test.html")
the first image in that window can be reached by
w.contentWindow.document.getElementsByTagName("img")[0].
I adapted the last example to overlay two maps in a separate window: The window is created with a sixth parameter: an HTML file that is put in the window at creation. This file just defines two overlaid images plus the JavaScript variables to access them: img1var and img2var. From outside the window, these variables are accessed as "w.contentWindow.img1var" and "w.contentWindow.img2var". They are set as targets for the two serverFrames, and nothing else has to be changed. The "onResize()" method also submits both serverFrames. The same idea has been applied in for setting image transparency in the browser.