Flex调Javascript方法打开新窗口的代码


Flex #互调2014-04-10 10:31

Flex通过调用Javascript打开全屏的新窗口。代码如下。

<?xml version="1.0" encoding="utf-8" ?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Script>
        <![CDATA[ private function openWindow(pageUrl:String,pageName:String):void{
        var jsString:String=""; jsString+=" var screenWidth=s creen.availWidth,
        screenHeight=s creen.availHeight;"; jsString+=" var args=' toolbar=no,
        menubar=no, scrollbars=no,resizable=yes,location=no, status=no';"; //打开全屏的新窗口
        jsString+=" var win=w indow.open('"+pageUrl+"','"+pageName+"',args);";
        jsString+=" if(win){"; jsString+=" win.resizeTo(screenWidth,screenHeight);";
        jsString+=" win.outerWidth=s creenWidth;"; jsString+=" win.outerHeight=s
        creenHeight;"; jsString+=" win.moveTo(0,0);"; jsString+=" }"; ExternalInterface.call("function(){"+jsString+"}");
        } protected function openButton_clickHandler(event:MouseEvent):void { openWindow("http://yige.org","一个网");
        } ]]>
    </fx:Script>
    <s:Button id="openButton" label="打开一个网" click="openButton_clickHandler(event)"
    />
</s:Application>


相关文章

粤ICP备11097351号-1