开发者

Flex: browser popup rather than Alert.show() type popup?

开发者 https://www.devze.com 2023-03-18 16:45 出处:网络
Im trying to create a browser popup window with some text, rather than using the Alert.show() or Flash Player level popups.

Im trying to create a browser popup window with some text, rather than using the Alert.show() or Flash Player level popups.

I have been looking around, and tried som开发者_Python百科e stuff with URI Data Scheme, but thought one of you guys might have done something similar before.

UPDATE: Answered Myself Below


You can use Flex's externalInterface API to call javascript functions. and thus to trigger a new popup dialog.

http://learn.adobe.com/wiki/display/Flex/External+Interface

http://www.quirksmode.org/js/popup.html

http://blog.flexexamples.com/2008/03/09/calling-javascript-functions-from-your-flex-applications-using-the-externalinterface-api/

UPDATE:

var urlstr:String = "javascript:NewWindow=window.open('"+<any string> +"','newWin','width=400,height=300,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No');  NewWindow.focus();void(0);");

    var url:URLRequest = new URLRequest(urlstr);


And you want the Flex window to stay open and just popup a new one right? From what I remember, this is not possible with Flash since it needs to go through Javascript (window.open), however, you might be able to call it directly using ExternalInterface:

if (ExternalInterface.available) 
{
   ExternalInterface.call("window.open", "http://www.adobe.com", "win", "height=200,width=300,toolbar=no,scrollbars=yes");
}

As for the url, you can specify your own or use the uri data scheme and it should work.


The following code does the trick:

<fx:Script>
    <![CDATA[
        import flash.net.navigateToURL;

        private function urlJump():void{

            var url:URLRequest = new URLRequest("javascript:NewWindow=window.open(''," +
                "'newWin','width=400,height=300,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No');  " +
                "NewWindow.focus();void(0); " +
                "NewWindow.document.write('hello');");

            navigateToURL(url, "_self" );

        }           
    ]]>
</fx:Script>
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>

<s:Button click="urlJump()" />

0

精彩评论

暂无评论...
验证码 换一张
取 消