日期:2014-05-16  浏览次数:20476 次

关于JS调用AS函数如何兼容FF 谷歌浏览器 IE
AS函数
ExternalInterface.addCallback("hehe",null,hehe);
function hehe(){
  return "哈哈";


HTML及JS
  <object id="MTheme" name="MTheme" type="application/x-shockwave-flash" data="$path/Maid/shell/shell1.swf" width="150" height="236">
<param name="allowScriptAccess" value="always" />
<param name="movie" value="$path/Maid/shell/shell1.swf" />
  <param name="quality" value="high" />
  <param name="wmode" value="opaque" />
  <param name="swfversion" value="8.0.35.0" />
  <param name="expressinstall" value="Scripts/expressInstall.swf" />
  </object>

<script type="text/javascript">
var s=window['MTheme']?window['MTheme']:document['MTheme'];
alert(s.hehe());
</script>

上面的代码在IE能调用成功 但是在 火狐 谷歌 内核中调用不了
请问如何兼容

------解决方案--------------------
document.getElementById("MTheme")呢
------解决方案--------------------
有人说,你需要等一会才能调用
你试试
setTimeout('document.getElementById("MTheme").hehe()',2000);

参见
http://www.psyked.co.uk/actionscript/externalinterface-not-working-in-firefox.htm
的讨论
------解决方案--------------------
对了非IE采用的是embed标签。

参见
http://tj007-bo.iteye.com/blog/579836