1.网页内嵌动态生成的flash出错,出错信息如下:
#25081850 myChartId::RendererManager Error >> There was an error rendering the chart. Enable FusionCharts JS debugMode for more information.
2.出错原因:chrome禁用flash插件
3.解决方法:
再动态生成flash之前,放置一个空白的flash,提示用户点击允许当前网站运行flash
空白flash代码如下:
<div id="flashEmpty" style="z-index: 5"> //空白flash <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"> <param name="wmode" value="transparent"> <embed src="media.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="200" height="115"></embed> </object> </div>
<div style="z-index: 6" id="chart1div" align="center" >你的动态生成flash位置</div>
<script type="text/javascript">
var width=document.body.clientWidth;
var chart1 = new FusionCharts("Gantt.swf", "myChartId", 500, 500, "0", "1");
chart1.setDataXML(动态生成的xml图表文件);
chart1.render("chart1div");
// 判断已经生成正常flash时隐藏空白flash
setTimeout(function(){
var obJ =document.getElementById("chart1div").childNodes;
var name = obJ[0].nodeName;
if(name.toUpperCase() == 'OBJECT'){
document.getElementById("flashEmpty").style.display = 'none'
}
},500)
</script>
4.如何检查是否用户已在chrome成功加入flash白名单
打开谷歌浏览器的空白页输入:chrome://settings/content/flash,查看允许名单内是否包含如下
5.这种处理方式的弊端
每次用户点击后,都会强制刷新页面