今天在给客户做网站的过程中,被客户提到的一个关于IE和Firefox兼容性的问题难住了,好好的图片幻灯片在IE下显示的好好的,可是到了FIREFOX里面就不显示了,刚开始还以为是FLASH的问题,结果找出几个以前用相同FLASH做的网站(变成语言不一样而已),在FIRFOX中都显示正常, 这下我开始怀疑是JS的问题,试了一下,果不其然,真的是JS的兼容性导致FLASH幻灯片不显示的,不过还好,因为西安百翔网络,有六年的西安网站建设和西安网站制作经验,所以处理这些问题还是没有任何问题的,于是测试了一下,问题终于找到了,是xmlhttp对象创建的问题,把代码改成一下代码,幻灯片终于访问正常了,测试了一下,兼容所有浏览器,百翔网络就一个字,开心,呵呵:
代码如下:
<!-- //焦点图顺序调整
var order = new Array("", "1", "2", "3", "4", "5");
var xb;
var pics = "";
var links = "";
var texts = "";
//---------------------------异步数据获取开始---------------------
if (window.ActiveXObject && !window.XMLHttpRequest)
{
window.XMLHttpRequest = function()
{
var MSXML = ['Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP'];
for (var i = 0; i < MSXML.length; i++)
{
try {
return new ActiveXObject(MSXML[i]);
}
catch (e){}
}
return null;
};
}
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("post", "flash.ashx", false);
xmlhttp.send("");
var res = xmlhttp.responseText
eval(res);
//---------------------------异步数据获取结束---------------------
var focus_width = 696
var focus_height = 298
var text_height = 0
var swf_height = focus_height + text_height
var j = 0;
for (i = 1; i <= 5; i++) {
xb = order[i];
if ((imgUrl[xb] != "") && (imgLink[xb] != "")) {
if (j != 0) {
pics = pics + "|";
links = links + "|";
texts = texts + "|";
}
pics = pics + imgUrl[xb];
links = links + imgLink[xb];
texts = texts + imgText[xb];
j++;
}
}
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=" http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + focus_width + '" height="' + swf_height + '">');
document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="flash/pixviewer.swf"><param name="quality" value="high"><param name="bgcolor" value="#dfdfdf">');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '">');
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" />');
document.write('</object>');
//-->
</script>