网页mp3播放器不兼容IE、Firefox及Chrome等浏览器的解决代码如下:
调用方法:
<script language=javascript> function showPlayer(id,url){ var vhtml='<object id="wmp"'; var userAg=navigator.userAgent; if(-1!=userAg.indexOf("MSIE")){ vhtml+='classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"'; }else if(-1!=userAg.indexOf("Firefox")||-1!=userAg.indexOf("Chrome")||-1!=userAg.indexOf("Opera")||-1!=userAg.indexOf("Safari")){ vhtml+='type="application/x-ms-wmp"'; } vhtml+='width="320" height="64">'; vhtml+='<param name="URL" value="'+url+'">'; vhtml+='<param name="autoStart" value="true">'; vhtml+='<param name="invokeURLs" value="false">'; vhtml+='<param name="playCount" value="100">'; vhtml+='<param name="Volume" value="100">'; vhtml+='<param name="defaultFrame" value="datawindow">'; vhtml+='</object>'; document.getElementByIdx_x(id).innerHTML=vhtml; } </script> |
调用方法:
<div id="CuPlayer"></div> <script type="text/javascript">showPlayer("CuPlayer","/fileupload'.$mp3.'")</script> |