让flash的弹出窗口不再被拦截

繁简对译:[]  字体设置:[] 2008-12-04  作者:wxy  来源:blueidea  阅读  次

正常如果我们在flash里执行open window的话,都会被浏览器给拦截了,需要点一下允许弹出窗口才行,因为flash是在它自己的容器里,而不是document里,所以无法取得浏览器的信任,那要取得浏览器的信任,就需要做一点小动作。

把wmode设置为opaque或者transparent,这样就能把flash添加到dom里,从而取得浏览器的信任。但如果这样设置的话,flash激活的时候,周围会有虚框,所以还要做一下手脚,就是把outline的属性设置为none。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>     
<title></title>     
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>   
<style type="text/css">         
object{            
    width:800px;            
    height:500px;            
    display:block;        
}         
object:focus{            
    outline:none;        
}        
</style>     
</head>   
<body>
    <object id="flash" type="application/x-shockwave-flash" data="movie.swf">        
    <param name="movie" value="movie.swf"/>        
    <param name="wmode" value="opaque"/>   
    </object>
</body>
</html>

 

import flash.external.ExternalInterface;
function openWindow(){
    var url:String = "http://www.blueidea.com";
    var windowName:String = "mywindow";
    var windowOptions:String = "width:800,height:600";
    ExternalInterface.call("window.open",url,windowName,windowOptions);
}
stage_btn.onRelease = function() {
    openWindow();
};

通过ExternalInterface,这样就不用去劳烦js里,直接在flash里面就可以搞定了。

打印 收藏 关闭