简体   繁体   English

在Adobe Flex桌面应用程序中打开网页

[英]Open Webpage in Adobe Flex Desktop Application

We are developing a small desktop application by using Adobe Flex. 我们正在使用Adobe Flex开发一个小型桌面应用程序。 In this application, we will have a screen with input box in which user will enter URL of any website and then enter. 在此应用程序中,我们将有一个带有输入框的屏幕,用户可以在其中输入任何网站的URL,然后输入。

After providing URL, the desktop application will open that webpage into the same screen just below the URL input box. 提供URL之后,桌面应用程序将在URL输入框正下方的同一屏幕中打开该网页。 Also we want to give an option to capture screenshot of that opened webpage manually(ie on button click). 我们还希望提供一个选项来手动捕获打开的网页的屏幕截图(即单击按钮)。

When the webpage is open in desktop app, then our screen should be work like browser ie we can go to any internal page by clicking webpage instead of providing another URL into input box. 当在桌面应用程序中打开网页时,我们的屏幕应该像浏览器一样工作,也就是说,我们可以通过单击网页转到任何内部页面,而不必在输入框中提供另一个URL。

We have searched lot of things regarding the same, but nothing got. 我们已经搜索了很多与此有关的东西,但没有任何结果。 Can anyone explain us, how can we implement this type of functionality into our desktop application? 谁能解释一下,我们如何在桌面应用程序中实现这种功能? or Is it possible to make this application using Adobe Flex? 或可以使用Adobe Flex制作此应用程序吗?

Your solution will be appreciated. 您的解决方案将不胜感激。 Thanks in advance. 提前致谢。

You can do that using the HTML control . 您可以使用HTML控件来实现

Take this example : 举个例子:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       width="920" height="580">

    <fx:Script>
        <![CDATA[

            protected function btn_history_back_clickHandler(event:MouseEvent):void
            {           
                // history back
                html_browser.historyBack();             
            }
            protected function btn_history_forward_clickHandler(event:MouseEvent):void
            {               
                // history forward
                html_browser.historyForward()
            }

            protected function btn_go_clickHandler(event:MouseEvent):void
            {
                var url:String = txt_url.text;              
                if(url != '')
                {   
                    if(url.substr(0, 4) == 'http')
                    {
                        // open the typed url
                        html_browser.location = url;
                    }                   
                }
            }

            protected function html_browser_locationChangeHandler(event:Event):void
            {
                // update our url text input
                txt_url.text = html_browser.location;
            }

        ]]>
    </fx:Script>

    <mx:HTML id="html_browser" x="6" y="39" width="905" height="511"
             locationChange="html_browser_locationChangeHandler(event)"/>
    <s:Button id="btn_forward" x="38" y="10" width="28" label="&gt;" click="btn_history_forward_clickHandler(event)"/>
    <s:Button id="btn_go" x="858" y="10" width="50" label="GO" click="btn_go_clickHandler(event)"
              enabled="true"/>
    <s:TextInput id="txt_url" x="74" y="10" width="775"/>
    <s:Button id="btn_back" x="10" y="10" width="28" label="&lt;" click="btn_history_back_clickHandler(event)"/>
</s:WindowedApplication>

Which will give you something like this ( it's the same window just I pressed the back button to show the different pages ) : 这会给你这样的东西(我按下后退按钮以显示不同的页面时,它是同一窗口):

在此处输入图片说明

Of course this is just a very simple example to show you how to start, you can improve and adapt it to your specific needs. 当然,这只是一个非常简单的示例,向您展示如何开始,可以对其进行改进并使之适应您的特定需求。

Hope that can help. 希望能对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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