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); }//if ie, else If (browsername = = "IE") {Externalinterface.call (window_open_function, URL, WINDOW, features); Externalinterface.call ("function Setwmwindow () {window.open ('" + URL + "');}"); If Safari else if (browsername = = "Safari") {Navigatetourl (Myurl, window); }//if Opera Else If (browsername = = "Opera") {Navigatetourl (Myurl, window); } 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;}"); Debug.text + = "Browser Info: [" + Browseragent + "]"; 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; } }}
In the era of AS2, only onrelease under the Geturl will be considered a complete click, Onpress will be intercepted
In the Navigatetourl era, even if you listen to a Mouseevent.click event, he will be intercepted, the reason I do not know now, who knows the words can be thread
So how to solve AS3 popup a _blank not be intercepted, 3 conditions
1. Determine the browser version, if it is Firefox and any other opera what the direct Navigatetourl, if it is IE, call window.open
2. Must listen to the Mouseevent.click event, if it's mouseevent.down, I can't guarantee it.
3.wmode properties must be set to opaque,transparent I haven't tried it, everybody can try it, but window certainly can't.
These 3 conditions are met in order to ensure that the popup new page is not blocked!!!!!!!!!!
AS3 Opening a window class