2009
07.14.

转自经典论坛:http://bbs.blueidea.com/thread-2838291-1-1.html 自己做个收藏
在ultrashock看到的,效果不错,共享之。

原文地址:http://www.ultrashock.com/forums … solution-92036.html

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

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd%22%3E%3Chtml">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html</a> lang="en" xml:lang="en" xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>">
<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>

AS3代码:

import flash.external.ExternalInterface;
function openWindow(){
    var <a href="String">url:String</a> = "<a href="http://www.blueidea.com">http://www.blueidea.com</a>";
    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里面就可以搞定了。

demo:
http://www.live-my-life-with-yuyi.com/misc/demo/open_window/

ps:偶然发现,adobe官网也有相关文章
http://www.adobe.com/cn/support/ … s/popup_windows.htm

评论暂缺 立即发表评论

还没有任何评论。

这篇文章上的评论的 RSS feed TrackBack URL

留下评论

页码: 1 of 0

©2009 All Rights Reserved. Powered by WordPress. Skin was designed by VDIT.com