今天在给客户做网站的过程中,被客户提到的一个关于IE和Firefox兼容性的问题难住了,好好的图片幻灯片在IE下显示的好好的,可是到了FIREFOX里面就不显示了,刚开始还以为是FLASH的问题,结果找出几个以前用相同FLASH做的网站(变成语言不一样而已),在FIRFOX中都显示正常, 这下我开始怀疑是JS的问题,试了一下,果不其然,真的是JS的兼容性导致FLASH幻灯片不显示的,不过还好,因为西安百翔网络,有六年的西安网站建设和西安网站制作经验,所以处理这些问题还是没有任何问题的,于是测试了一下,问题终于找到了,是xmlhttp对象创建的问题,把代码改成一下代码,幻灯片终于访问正常了,测试了一下,兼容所有浏览器,百翔网络就一个字,开心,呵呵:
代码如下:
02 | var order = new Array( "" , "1" , "2" , "3" , "4" , "5" ); |
08 | if (window.ActiveXObject && !window.XMLHttpRequest) |
10 | window.XMLHttpRequest = function () |
12 | var MSXML = [ 'Msxml2.XMLHTTP.5.0' , 'Msxml2.XMLHTTP.4.0' , 'Msxml2.XMLHTTP.3.0' , 'Msxml2.XMLHTTP' , 'Microsoft.XMLHTTP' ]; |
13 | for ( var i = 0; i < MSXML.length; i++) |
16 | return new ActiveXObject(MSXML[i]); |
24 | var xmlhttp = new XMLHttpRequest(); |
25 | xmlhttp.open( "post" , "flash.ashx" , false ); |
27 | var res = xmlhttp.responseText |
33 | var swf_height = focus_height + text_height |
36 | for (i = 1; i <= 5; i++) { |
38 | if ((imgUrl[xb] != "" ) && (imgLink[xb] != "" )) { |
44 | pics = pics + imgUrl[xb]; |
45 | links = links + imgLink[xb]; |
46 | texts = texts + imgText[xb]; |
51 | document.write( '<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="flash/pixviewer.swf"><param name="quality" value="high"><param name="bgcolor" value="#dfdfdf">' ); |
52 | document.write( '<param name="menu" value="false"><param name=wmode value="opaque">' ); |
53 | document.write( '<param name="FlashVars" value="pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '">' ); |
54 | document.write( '<embed src="flash/pixviewer.swf" wmode="opaque" FlashVars="pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '" menu="false" bgcolor="#dfdfdf" quality="high" width="' + focus_width + '" height="' + focus_height + '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage=" http://www.macromedia.com/go/getflashplayer" />' ); |
55 | document.write( '</object>' ); |