由于很多移动终端不支持 Flash,因此 许多绚丽多彩的 Flash效果出不来。如果,能够判断出访问Web网页的类型(PC还是移动终端)。就可以对症下药,找出解决的办法! 访问的类型为移动终端我们就用.gif代替Flash(.swf后缀)动画,PC端就不做改变。这样就比较完美了! 如下所示,函数 flashChecker() 就是用来检测访问的类型。 复制代码 代码如下: <BR>/* <BR>*用来检测是 PC还是移动终端 <BR>*返回:flashChecker().f == true PC终端 <BR>* 反之为移动终端 <BR>*/ <BR>function flashChecker() { <BR>var hasFlash = 0; <BR>var flashVersion = 0; <BR>var isIE = /*@cc_on!@*/0; <BR>if (isIE) { <BR>var swf = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); <BR>if (swf) { <BR>hasFlash = 1; <BR>VSwf = swf.GetVariable("$version"); <BR>flashVersion = parseInt(VSwf.split(" ")[1].split(",")[0]); <BR>} <BR>} <BR>else { <BR>if (navigator.plugins && navigator.plugins.length > 0) { <BR>var swf = navigator.plugins["Shockwave Flash"]; <BR>if (swf) { <BR>hasFlash = 1; <BR>var words = swf.description.split(" "); <BR>for (var i = 0; i < words.length; ++i) { <BR>if (isNaN(parseInt(words[i]))) { <BR>continue; <BR>} <BR>flashVersion = parseInt(words[i]); <BR>} <BR>} <BR>} <BR>} <BR>return { <BR>f: hasFlash, v: flashVersion <BR>}; <BR>} <BR> 扩充: 复制代码 代码如下: <BR>/* <BR>* 根据参数 输出swf动画 <BR>* url :单击 swf动画 后的跳转地址 <BR>* swfLink: *.swf 素材地址 <BR>*/ <BR>function GetSwfHtml(url, swfLink) { <BR>html = "<a style='position: absolute; top: 0; left: 0; bottom: 0; right: 0; display: block; " + <BR>"width: 100%; height: expression(this.parentNode.scrollHeight); filter: alpha(opacity=0);" + <BR>"opacity: 0; background: #FFF;' href='" + url + "' target='_blank'>" + <BR>"" + <BR>"<object width='590' height='55' align='middle'>" + <BR>"<param name='allowScriptAccess' value='never' />" + <BR>"<param name='quality' value='high' />" + <BR>"<param name='wmode' value='transparent' />" + <BR>"<param name='movie' value='" + swfLink+ "' />" + <BR>"<embed wmode='transparent' src='" + swfLink+ "' quality='high' " + <BR>"width='590' height='55' align='middle' allowscriptaccess='never' type='application/x-shockwave-flash' " + <BR>"pluginspage='" + url + "' />" + <BR>""; <br><br><BR>return html; <BR>} <BR>