By Daniel Du
When developing with flexible web layout, we always need to get the global object Fusion. Sometimes you may get error message: ' Fusion is undefined' if you do not get it correctly.
Actually, how to get the Fusion object depends on how you embed the fusion viewer into your webpage and where you call your JavaScript to get it. Generally speaking, if you are not using <frame> or <iframe> when embedding fusion viewer, following code snippet should work for you.
var MainFusionWindow = GetFusionWindow();
var OpenLayers = MainFusionWindow.OpenLayers;
var Fusion = MainFusionWindow.Fusion;
alert(Fusion);
/* locate the Fusion window */
function GetFusionWindow() {
var curWindow = window;
while (!curWindow.Fusion) {
if (curWindow.parent && curWindow != curWindow.parent) {
curWindow = curWindow.parent;
} else if (curWindow.opener) {
curWindow = curWindow.opener;
} else {
alert('Could not find Fusion instance');
break;
}
}
return curWindow;
}
Hope this helps.