日期:2014-05-17  浏览次数:20750 次

html页面中利用object标签加载swf的方式弹出窗口时被拦截的解决方法

1、修改前的代码:

?

object标签中有使swf透明的参数:<param name="wmode" value="opaque" />和wmode="opaque"

?

?

function showFocusActImg(img_urls,target_urls) {	

var swf_width=960,swf_height=240,mvUrl="Main.swf";

document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="'+ swf_width +'" height="'+ swf_height +'">');
document.write('<param name="movie" value="'+ mvUrl + '" /><param name="quality" value="high" />');
document.write('<param name="allowScriptAccess" value="always" /> <param name="wmode" value="opaque" />');
document.write('<param name="FlashVars" value="img_urls='+ img_urls +'&target_urls='+ target_urls +'" />');
document.write('<embed src="'+ mvUrl + '"  wmode="opaque"  FlashVars="img_urls='+ img_urls +'&target_urls='+ target_urls +'" quality="high" allowScriptAccess="sameDomain"  width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');

}

?

相关的截图:

?


?

?

?

2、修改后的代码:

?

?

function showFocusActImg(img_urls,target_urls) {	

var swf_width=960,swf_height=240,mvUrl="Main.swf";

document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="'+ swf_width +'" height="'+ swf_height +'">');
document.write('<param name="movie" value="'+ mvUrl + '" /><param name="quality" value="high" />');
document.write('<param name="allowScriptAccess" value="always" />');
document.write('<param name="FlashVars" value="img_urls='+ img_urls +'&target_urls='+ target_urls +'" />');
document.write('<embed src="'+ mvUrl + '" FlashVars="img_urls='+ img_urls +'&target_urls='+ target_urls +'" quality="high" allowScriptAccess="sameDomain"  width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');

}

?

?

相关截图:

?


?

本人的测试环境是winXP SP2+IE7。

?

结论:object标签让swf透明的参数会影响swf中弹出新窗口的动作,正上面所示,加了透明参数弹出的新窗口会被IE拦截。另外,为了保险起见,embed 中的wmode="opaque"设置透明的属性我也一起去掉,这个属性是否也会影响弹出窗口被拦截,还没进行测试。

?

?

?

?