简体   繁体   中英

Bypass IE Popup Blockers when Opening up links in flash?

This is the Class I'm using to bypass the popup blocker.

This is the function to call to the class function

function linkHandler(e:MouseEvent):void{
popup.ChangePage(linksURLArray[e.currentTarget.name], "_self");
}

this is the class.

package com.dbd.external {
    import flash.external.ExternalInterface;
    import flash.net.*;
    public class PassPopup {
        public function ChangePage(url:*, window:String = "_blank"):void {
            var req:URLRequest = url is String ? new URLRequest(url) : url;
            if (!ExternalInterface.available) {
                navigateToURL(req, window);
            } else {
                var strUserAgent:String = String(ExternalInterface.call("function() {return navigator.userAgent;}")).toLowerCase();
                if (strUserAgent.indexOf("firefox") != -1 || (strUserAgent.indexOf("msie") != -1 && uint(strUserAgent.substr(strUserAgent.indexOf("msie") + 5, 3)) >= 7)) {
                    ExternalInterface.call("window.open", req.url, window);
                } else {
                    navigateToURL(req, window);
                }
            }
        }
    }

} 

I'm working locally, http://localhost/ and trying to link externally to another domain.

Be sure to include in your AS code. ExternalInterface requires the allowDomain to be set when HTML-SWF cross-scripting is performed even though it's local to your browser.

System.security.allowDomain("*");

Plus be sure to add the following in your Flash embed HTML

allowscriptaccess="always" 

If that does not work then add a crossdomain.xml like the following:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>

And add the following to your AS code:

System.security.loadPolicyFile("http://yourdomain.com/crossdomain.xml");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM