获取IE对象以控制闪光按钮

Get IE object to control flash buttons

本文关键字:按钮 控制 IE 对象 获取      更新时间:2023-09-26

在下面的代码中,flash中有一些按钮,我正试图让html按钮可以访问这些按钮。因此,当按下记录按钮时,模式将为"记录",并调用record_functions()。我可以在Firefox上使用它,但在internet explorer中,按钮似乎不起作用,即无法从internet explorer调用flash功能。请让我知道如何解决这个问题

 function thisMovie(movieName)
 {
 if (window.document[movieName])
  {
     return document.getElementById(movieName);
  }
 if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName];
   }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
   return document.getElementById(movieName);
   }
  }

 function record_functions(mode)
 {
  if(mode == "record")
  {
     thisMovie("audiorecoding").startRecording();
  }
  else if(mode == "stop")
  {
     thisMovie("audiorecoding").stopRecording();
  }
  else if(mode == "play")
  {
        thisMovie("audiorecoding").playRecording();
  }
  else if(mode == "pause")
  {
        thisMovie("audiorecoding").pauseRecording();
  }
 }
 <input type="button" onclick="record_functions('record')" value="Record" />

您应该在IE上使用id属性,但在其他浏览器中使用name属性

if (navigator.appName.indexOf("Microsoft") == -1)
    swfObject = document["mozillaEmbedName"];
else
    swfObject = window["ieObjectID"];

如果是参考错误(找不到闪存),您没有指定得到的错误

我建议使用swfobject,它将返回对您的对象的引用,请查看:http://code.google.com/p/swfobject/