Autodesk 15606-011408-9300 Developer Guide - Page 77
JavaScript Example, both the Autodesk MapGuide Viewer Plug-In and Autodesk MapGuide
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 77 highlights
JavaScript Example The following JavaScript example shows an HTML page that handles the onSelectionChanged event for both Netscape Navigator and Microsoft Internet Explorer browsers: if (navigator.appName() == "Netscape") { // Embed the Autodesk MapGuide Viewer Plug-In Observer Applet document.write(""); document.write(""); } function onLoad() { if (navigator.appName() == "Netscape") getMap().setSelectionChangedObserver(document.obs); } function onSelectionChanged(map) { alert("Selection Changed"); } If this script is loaded in Netscape Navigator, it first adds an tag to the document, which loads the MapGuideObserver6.class applet. The tag must be added in this manner or the page will not load correctly in Internet Explorer. The applet is given the name obs. After the page loads, the browser automatically calls the onLoad function. onLoad calls the setSelectionChangedObserver method from MGMap, providing the Autodesk MapGuide Viewer Plug-In and its observer applet with the observer object that handles selection changed events. Finally, the map_onSelectionChanged function is implemented to handle the event in JavaScript. This one function will now handle selection changed events from both the Autodesk MapGuide Viewer Plug-In and Autodesk MapGuide Viewer ActiveX Control. To see a fully functional event handling example, choose Help ➤ Contents ➤ Examples Advanced ➤ Event Handling in the Autodesk MapGuide Viewer API Help. This example implements an observer object that supports all of the observer interfaces by forwarding the events back to JavaScript functions that have identical semantics to the Autodesk MapGuide Viewer ActiveX Control event handlers. Setting Up Event Handlers | 77