下面这段JS代码是中国雅虎首页用来显示flash的。我在开发IE MIME过滤时,发现中国雅虎首页中的flash都不显示了,但其它网站都未发现这个问题。所以我怀疑是雅虎的代码有问题。并不是说代码错了,我认为它可能设了一些条件判断,在某些条件不成立时就不显示flash。小弟并不是做网页开发的,还请本版的大虾们帮个忙,看看代码中是否有这样的条件判断。
(function(){com_tanx=window.com_tanx||{};
com_tanx.p=com_tanx.p||{};
com_tanx.p.show=(function(d,b,a,g,c){var f=c?c:window;
var e=c?c.document:document;
if(b){window.setTimeout((function(){b.insertAdjacentHTML("beforebegin",d);
if(typeof g=="function"){g()}}),0)}else{if(a){window.setTimeout((function(){a.insertAdjacentHTML("afterbegin",d);
if(typeof g=="function"){g()}}),0)}else{e.write(d);
if(typeof g=="function"){g()}}}})})();(function(){com_tanx=window.com_tanx||{};
com_tanx.acookie=com_tanx.acookie||{};
com_tanx.acookie.exec=com_tanx.acookie.exec||(function(b){if(!com_tanx.acookie.loaded){com_tanx.acookie.loaded=true;
if(b==""||location.host.indexOf("www.taobao.com")<0){var c=document;
var a=c.createElement("iframe");
a.style.width="0px";
a.style.height="0px";
a.style.borderWidth="0px";
a.style.display="none";
a.marginWidth=0;
a.marginHeight=0;
a.frameBorder=0;
a.src="http://cdn.tanx.com/t/acookie/acbeacon2.html";
c.body.insertBefore(a,c.body.firstChild)}}})})();
(function(a){com_tanx=window.com_tanx||{};
com_tanx.p=com_tanx.p||{};
com_tanx.p[a]=(function(e,l,k,j){var b=0,m,p,g,d,n;
function h(r,c,i,q){var f='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+c+'px" height="'+i+'px" align="middle"><param name="allowScriptAccess" value="never" />';
if(q){f+='<param name="flashvars" value="'+q+'" />'}f+='<param name="movie" value="'+r+'" /><param name="wmode" value="transparent" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="'+r+'" quality="high" bgcolor="#ffffff" width="'+c+'" height="'+i+'" ';
if(q){f+='flashvars="'+q+'" '}f+='align="middle" allowScriptAccess="never" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
return f}m="tanx_displayframe_"+e.pid;
n="tanx_frameanchor_"+e.pid;
d="<a style='display:none !important;
' id='"+n+"'></a>";
p='<iframe id="'+m+'" width="'+e.width+'" height="'+e.height+'"';
if(navigator.userAgent.toLowerCase().indexOf("msie")>-1&&document.domain!=location.hostname){p+=" src=\"javascript:void((function(){var d=document;
d.open();
d.domain='"+document.domain+"';
d.write('');
d.close();
})())\""}else{p+=' src="about:blank"'}p+=' border="0" frameborder="0" scrolling="no" marginwidth="0" allowTransparency="true" marginheight="0"  style="border: 0pt none;
"></iframe>';
g='<!doctype html><html><head><meta charset="gbk" /></head><body style="margin:0px;
padding:0px">';
g+='<div style="float:left;
z-index:100;
position:absolute;
width:'+e.width+"px;
height:"+e.height+'px;
">';
g+=h(e.data,e.width,e.height)+"</div>";
g+='<div style="float:left;
overflow:hidden;
z-index:1000;
position:absolute;
width:'+e.width+"px;
height:"+e.height+'px;
">';
g+='<a style="position:absolute;
height:100%;
width:100%;
overflow:hidden;
font-size:900px;
" target="_blank" href="'+e.clickurl+'">&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
</a></div>';
g+="</body></html>";
com_tanx.p.show(d,l,k,(function(){var c=(j||window).document.getElementById(n);
if(c){(function(i){if(i>20){return}var r,s,q=arguments.callee;
if(c.insertAdjacentHTML){c.insertAdjacentHTML("beforebegin",p)}else{var f=(j||window).document.createElement("div");
f.innerHTML=p;
c.parentNode.inserBefore(f.getEelementsByTagName("iframe")[0],c)}r=(j||window).document.getElementById(m);
setTimeout((function(){try{s=r.contentWindow.document;
if(s.body.insertAdjacentHTML){s.body.insertAdjacentHTML("afterbegin",g)}else{setTimeout((function(){(j||window).document.getElementById(m).contentWindow.document.body.innerHTML=g}),0)}}catch(t){r.parentNode.removeChild(r);
if(!i){i=1}else{i++}q(i)}}),20)})()}else{b++;
if(b<2){window.setTimeout(arguments.callee,50)}}}),j)})})("flash");
com_tanx.p["flash"](/*![JDATA[*/{"width":"350","height":"200","title":"0617-R3-p4p","clickurl":"http:\/\/click.tanx.com\/cc?e=6clmJzPBQVj%2BEs6W2wygkhsQmLP5zomM2KvQfvxaK2UFoFKJs6uaELtiskDapLEXgNjMS1JtlHEvPiecf9oIWtAT3ZS%2FrUsKt7QpNn%2B%2FZwNGQCtCKsHRb9EMsRbnneDyxMN5nY9K1MVquXazIVdf85AADIfjjxhXVlxx%2BixFeUriTvh9ZTYv9g%3D%3D&u=http%3A%2F%2Fclick.mz.simba.taobao.com%2Frd%3Fw%3Dmmp4ptest%26f%3Dhttp%253A%252F%252Fre.taobao.com%252Fsearch%253F_input_charset%253Dutf-8%2526refpid%253Dmm_14604213_2080344_8615480%2526keyword%253D%2525E7%25259C%25259F%2525E4%2525B8%25259D%2525E8%2525BF%25259E%2525E8%2525A1%2525A3%2525E8%2525A3%252599%2526refpos%253Drefposplaceholder%2523ListView%26k%3Dc624173611405a66&k=185","data":"http:\/\/img.mmcdn.cn\/t\/20110617\/201106171844098446.swf","pid":"mm_17230573_2278684_8962768","adboardtype":"flash"}/*!]JDATA]*/, document.getElementById("tanx-a-mm_17230573_2278684_8962768"));
try{com_tanx.acookie.exec('')}catch(err){};

解决方案 »

  1.   

    问题基本解决。问题原因是没有意识到JS源码其实也属于"text/html"范围。我发现那些用于显示flash的JS代码也被列入了我的MIME过滤名单。比如
    <script charset="gbk" src="http://p.tanx.com/ex?i=mm_17230573_2278684_8962768"></script>
    这里面的http://p.tanx.com/ex?i=mm_17230573_2278684_8962768我至今不解的是,即使我在MIME中不加任何处理直接将得到的数据返回,flash还是显示不出来--我不知道到底是哪里导致JS源码失真的。我目前办法是根据正则找到所有<script>标签,凡是JS相关的,Start函数中返回INET_E_USE_DEFAULT_PROTOCOLHANDLER。这样才避免了数据失真,flash终于重见天日。