今天折腾了一下午终于解决了这个问题。
在IE下不被拦截的情况有这么几种:
1. 如果是window模式的话,直接使用 navigateToURL . (MOUSE_DOWN,MOUSE_UP,CLICK)下都可以。
2. 如果是其他两种模式的话,需要借助JS弹窗的形式绕过拦截,具体做法就是:重点在最下面
http://hereson.iteye.com/blog/194260
package FlashCode.utils{ import flash.display.Sprite; import flash.net.URLRequest; import flash.net.navigateToURL; import flash.external.ExternalInterface; public class openWindow { public function openWindow(url:String, window:String="_blank", features:String=""){ var WINDOW_OPEN_FUNCTION:String = "window.open"; var myURL:URLRequest = new URLRequest(url); var browserName:String = getBrowserName(); if(getBrowserName() == "Firefox"){ ExternalInterface.call(WINDOW_OPEN_FUNCTION, url, window, features); }else if(browserName == "IE"){ ExternalInterface.call(WINDOW_OPEN_FUNCTION, url, window, features); }else if(browserName == "Safari"){ navigateToURL(myURL, window); }else if(browserName == "Opera"){ navigateToURL(myURL, window); }else{ navigateToURL(myURL, window); } } private function getBrowserName():String{ var browser:String; var browserAgent:String = ExternalInterface.call("function getBrowser(){return navigator.userAgent;}"); if(browserAgent != null && browserAgent.indexOf("Firefox") >= 0) { browser = "Firefox"; }else if(browserAgent != null && browserAgent.indexOf("Safari") >= 0){ browser = "Safari"; }else if(browserAgent != null && browserAgent.indexOf("MSIE") >= 0){ browser = "IE"; }else if(browserAgent != null && browserAgent.indexOf("Opera") >= 0){ browser = "Opera"; }else{ browser = "Undefined"; } return browser; } } }
最关键的是嵌套模式使用非window模式,并且按钮的鼠标事件必须是MOUSE_UP或者CLICK,如果使用MOUSE_DOWN肯定是不行的。