AS3 Opening a window class

Source: Internet
Author: User

 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.