IE8 對 `
<iframe src="map.swf"></iframe> <!-- IE8 直接載入 SWF 會被阻擋 -->
<!-- 主頁面 -->
<iframe src="mapContainer.html" width="100%" height="500" frameborder="0"></iframe>
<!-- mapContainer.html -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<style>html,body{margin:0;padding:0;width:100%;height:100%;overflow:hidden;}</style>
</head>
<body>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
width="100%" height="100%" id="mapFlash">
<param name="movie" value="map.swf" />
<param name="allowScriptAccess" value="always" />
<param name="wmode" value="opaque" /> <!-- 避免遮蓋下拉選單 -->
<!--[if !IE]><!-->
<object type="application/x-shockwave-flash" data="map.swf" width="100%" height="100%">
<param name="allowScriptAccess" value="always" />
<param name="wmode" value="opaque" />
</object>
<!--<![endif]-->
</object>
</body>
</html>
// 主頁面 JS
function callFlash(method, ...args) {
const iframe = document.querySelector('iframe[src="mapContainer.html"]');
const flash = iframe.contentWindow.document.getElementById('mapFlash');
if (flash && flash[method]) flash[method](...args);
}
// 呼叫 Flash 公開的函式
callFlash('gotoLocation', 121.5, 25.0);
Flash 端需 `ExternalInterface.addCallback("gotoLocation", gotoLocation);` 註冊。
「iframe 載入 HTML,HTML 再嵌入 Flash」是繞過 IE8 直接載入 SWF 限制的標準模式。