<script language="javascript" type="text/javascript"> /* *用来检测是 PC还是移动终端 *返回:flashChecker().f == true PC终端 * 反之为移动终端 */ function flashChecker() { var hasFlash = 0; var flashVersion = 0; var isIE = /*@cc_on!@*/0; if (isIE) { var swf = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); if (swf) { hasFlash = 1; VSwf = swf.GetVariable("$version"); flashVersion = parseInt(VSwf.split(" ")[1].split(",")[0]); } } else { if (navigator.plugins && navigator.plugins.length > 0) { var swf = navigator.plugins["Shockwave Flash"]; if (swf) { hasFlash = 1; var words = swf.description.split(" "); for (var i = 0; i < words.length; ++i) { if (isNaN(parseInt(words[i]))) { continue; } flashVersion = parseInt(words[i]); } } } } return { f: hasFlash, v: flashVersion }; } 《script》
扩充:
<script language="javascript" type="text/javascript"> /* * 根据参数 输出swf动画 * url :单击 swf动画 后的跳转地址 * swfLink: *.swf 素材地址 */ function GetSwfHtml(url, swfLink) { html = " " + " "; return html; } 《script》
更多Javascript自定义函数判断网站访问类型是PC还是移动终端相关文章请关注PHP中文网!