[AS3]flash在web中弹出窗口被拦截阻止的解决方法
[AS3]flash在web中弹出窗口被拦截阻止的解决方法
[AS3]flash在web中弹出窗口被拦截阻止的解决方法
- package com.ylsoft.lib{
- import flash.external.ExternalInterface;
- import flash.net.URLRequest;
- import flash.net.navigateToURL;
- public class WebWindow {
- 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() == "maxthon"){
- navigateToURL(myURL, window);
- }
- //If IE,
- else if(browserName == "firefox"){
- navigateToURL(myURL, window);
- }
- //If Safari
- else if(browserName == "chrome"){
- ExternalInterface.call(WINDOW_OPEN_FUNCTION, url, window, features);
- }
- //If Opera
- else if(browserName == "msie"){
- ExternalInterface.call(WINDOW_OPEN_FUNCTION, url, window, features);
- }
- else if(browserName == "safari"){
- ExternalInterface.call(WINDOW_OPEN_FUNCTION, url, window, features);
- }
- else {
- navigateToURL(myURL, window);
- }
- /*Alternate methodology...
- var popSuccess:Boolean = ExternalInterface.call(WINDOW_OPEN_FUNCTION, url, window, features);
- if(popSuccess == false){
- navigateToURL(myURL, window);
- }*/
- }
- private function getBrowserName():String{
- var browser:String;
- //Uses external interface to reach out to browser and grab browser useragent info.
- var browserAgent:String = ExternalInterface.call("function getBrowser(){return navigator.userAgent.toLowerCase();}");
- // Debug.text += "Browser Info: [" + browserAgent + "]";
- //Determines brand of browser using a find index. If not found indexOf returns (-1).
- if(browserAgent != null && /(.*)maxthon(.*)/.test(browserAgent)) {
- browser = "maxthon";
- }
- else if(browserAgent != null && /(.*)firefox(.*)/.test(browserAgent)){
- browser = "firefox";
- }
- else if(browserAgent != null && /(.*)chrome(.*)/.test(browserAgent)){
- browser = "chrome";
- }
- else if(browserAgent != null && /(.*)msie(.*)/.test(browserAgent)){
- browser = "msie";
- }
- else if(browserAgent != null && /(.*)mozilla(.*)/.test(browserAgent) && !/(.*)firefox(.*)/.test(browserAgent) && !/(.*)chrome(.*)/.test(browserAgent) && !/(.*)msie(.*)/.test(browserAgent)){
- browser = "safari";
- }
- return browser;
- }
- }
- }
[AS3]flash在web中弹出窗口被拦截阻止的解决方法
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...