Flash: How to prevent pop-up blocking in Firefox
Hi, I just want to point out some class that I find very useful. It help you no to block FF pop, when you call navigateToURL method. So here is the link:
Here I will post the actionscript file, because when you copy it from the location it copies you also the numbers, which is kind of annoying.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | package com.stanislavstankov.utils { import flash.external.ExternalInterface; import flash.net.URLRequest; import flash.net.navigateToURL; /** * Collection of URL util functions. * * ActionScript 3.0 / Flash 9 * * @package com.apdevblog.utils * @author Philipp Kyeck / phil@apdevblog.com * @copyright 2008 apdevblog.com * @version SVN: $Id: URLUtils.as 19 2008-04-08 09:57:50Z phil $ * * based on script by * @author Sergey Kovalyov * @see http://skovalyov.blogspot.com/2007/01/how-to-prevent-pop-up-blocking-in.html * * and based on script by * * @author Jason the Saj * @see http://thesaj.wordpress.com/2008/02/12/the-nightmare-that-is-_blank-part-ii-help */ public final class URLUtils { protected static const WINDOW_OPEN_FUNCTION:String = "window.open"; /*------------------------------------ Constructor ------------------------------------*/ public function URLUtils():void { } /*------------------------------------ Public methods ------------------------------------*/ /** * Open a new browser window and prevent browser from blocking it. * * @param url url to be opened * @param window window target * @param features additional features for window.open function */ public static function openWindow(url:String, window:String = "_blank", features:String = ""):void { var browserName:String = getBrowserName(); if (getBrowserName() == "Firefox") { ExternalInterface.call(WINDOW_OPEN_FUNCTION, url, window, features); } else if (browserName == "IE") { ExternalInterface.call("function setWMWindow() {window.open('" + url + "');}"); } else if (browserName == "Safari") { navigateToURL(new URLRequest(url), window); } else if (browserName == "Opera") { navigateToURL(new URLRequest(url), window); } else { //Otherwise, use Flash's native 'navigateToURL()' function to pop-window. //This is necessary because Safari 3 no longer works with the above ExternalInterface work-a-round. navigateToURL(new URLRequest(url), window); } } /*------------------------------------ Private methods ------------------------------------*/ /** * return current browser name. */ private static 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;}"); //Determines brand of browser using a find index. If not found indexOf returns (-1). 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); } } } |
I do not pretend in any way of that I write or have part of writing this class. Only distributing it

This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution 2.5 Bulgaria License.