open block

I have updated previous technique since firefox will still block it.  Previous post left below, but this technique comes from here:

http://skovalyov.blogspot.com/2007/01/how-to-prevent-pop-up-blocking-in.html

Basically, make a call to an AS function that does this:

    var url1:String = new String();
    url1 = "http://www.macys.com/";
    // This method of opening window gets around popup blockers   
    ExternalInterface.call("window.open", url1, "_blank", "");
   
You could also use ExternalInterface to call a javascript popup function to size the popup (the above code just opens a new window).

hope it works for ya'll...



previous post

In main Flex script tag, create this function:

   // function below opens window without getting it blocked       
     private function openNewWindow(event:MouseEvent, url:String, winName:String, w:int, h:int, toolbar:int, location:int, directories:int, status:int, menubar:int, scrollbars:int, resizable:int):void {
       
        var fullURL:String = "javascript:var myWin; if(!myWin || myWin.closed){myWin = window.open('" + url + "','" + winName + "','" + "width=" + w + ",height=" + h + ",toolbar=" + toolbar + ",location=" + location + ",directories=" + directories + ",status=" + status + ",menubar=" + menubar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",top='+((screen.height/2)-(" + h/2 + "))+',left='+((screen.width/2)-(" + w/2 + "))+'" + "')}else{myWin.focus();};void(0);";
        var u:URLRequest = new URLRequest(fullURL);
        navigateToURL(u,"_self");
               
     }


Then, use this code on a button or link to pop up the window:

        <mx:Button
            click="openNewWindow(event, 'http://www.adobe.com/', 'candiespop', 800, 600, 1, 1, 1, 1, 1, 1, 1);"
            id="test link"
            useHandCursor="true"
            buttonMode="true"
            mouseChildren="false" />

To determine if the new window has toolbars, menubars, etc you can set a 0 or 1 for those fields when calling the function.  There are actually several ways to do this, but this one seemed easiest to manage to me.

Have fun.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值