Show URL for link to AIR HTML control

Does anyone know if there is an easy way to catch the link freezing URL in an AIR HTML control? As in the browser, I would like the URL to appear in the status bar, but I cannot find any event that occurs when the link is wrapped. Do I need to check and possibly manage the DOM itself for this?

+3
source share
1 answer

Assuming you are using mx: HTML or HTMLLoader, you probably have to write a little script to connect the DOM objects to the AIR container. Here, one way to do this is probably a more elegant solution, but it should be enough to illustrate.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1024" height="768" xmlns:html="flash.html.*" horizontalScrollPolicy="off">

    <mx:Script>
        <![CDATA[

            private function container_complete(event:Event):void
            {
                addHTMLListeners();
            }

            private function addHTMLListeners():void
            {
                var links:Object = container.htmlLoader.window.document.getElementsByTagName("a");

                for (var i:int = 0; i < links.length; i++)
                {
                    if (links[i].href != "")
                    {
                        var href:String = links[i].href;

                        links[i].onmouseover = function():void { setStatus(this); };
                        links[i].onmouseout = function():void { clearStatus() };
                    }
                }
            }

            private function setStatus(o:Object):void
            {
                status = o.href;
            }

            private function clearStatus():void
            {
                status = "";
            }

        ]]>
    </mx:Script>

    <mx:HTML id="container" location="http://stackoverflow.com/users/32129" width="100%" height="100%" complete="container_complete(event)" />

</mx:WindowedApplication>

Hope this helps!

+4
source

Source: https://habr.com/ru/post/1702981/


All Articles