Select to view content in your preferred language

navigateToURL question

1249
3
Jump to solution
09-05-2013 06:18 AM
MayJeff
Deactivated User
I try to run a test to create a button that can open an url link on new window when user click on it and use the same child window if one already opened.  So how do you make the child window stay focus when user click again?  Didn't find much information on flash to close child window.
Here is the simple code:
private function openWebsite():void
   {
    var url:String;
    url="http://esri.com"
    var myURL:URLRequest = new URLRequest(url);
    navigateToURL(myURL, "child");

   }

and
<mx:Button label="ESRI website" click="openWebsite()"/>

Thanks.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
IsaiahAguilera
Frequent Contributor
I am not aware of a way to make flex focus on a child window that is a popup.  You might have to use some type of ExternalInterface and have javascript do the work.  The concept of using ExternalInterface is demonstrated on this site.
http://www.adobe.com/devnet/flex/articles/flex_javascript.html

View solution in original post

0 Kudos
3 Replies
IsaiahAguilera
Frequent Contributor
Your question is a little confusing. Do you want to keep the link from opening a new window?
If so then you would use this.
navigateToURL(new URLRequest(URL), '_self');


If you want a new window open then you would use this.
navigateToURL(new URLRequest(URL), '_blank');


The window argument of the navigateToURL function is what you want to change.
This is from Flex Documentation:
Window: The browser window or HTML frame in which to display the document indicated by the request parameter. You can enter the name of a specific window or use one of the following values:  
"_self" specifies the current frame in the current window. 
"_blank" specifies a new window. 
"_parent" specifies the parent of the current frame. 
"_top" specifies the top-level frame in the current window. 


Not sure if that's what you were getting at but hope this helps.
0 Kudos
MayJeff
Deactivated User
Actually I don't want the link to keep opening a new window.  If user click the first time, a new window will open then if user click again and able to use the same child window just opened.  But I can't get second click for child window to be focus like setting  _blank for new window that open new window and stay focus all the time.

JavaScript able to close child window and tested the code below.  Not sure how flash can do so.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test Page</title>
    <script type="Text/javascript">
        var theChild;
       

        function OpenWindow()
        {
        if(theChild!=null)
        {
         if(!theChild.closed)
         {
          theChild.close();
         }
        }
         url='http://www.esri.com';
         theChild = window.open(url, 'theChild', 'menubar=no,location=no,resizable=no,toolbar=no,scrollbars=auto');
        }
    </script>


</head>
<body>
    <form id="form1" runat="server">
        <div>
            <input type="button" id="btnOpen" onclick="OpenWindow()" value="open" />
        </div>
    </form>
</body>
</html>
0 Kudos
IsaiahAguilera
Frequent Contributor
I am not aware of a way to make flex focus on a child window that is a popup.  You might have to use some type of ExternalInterface and have javascript do the work.  The concept of using ExternalInterface is demonstrated on this site.
http://www.adobe.com/devnet/flex/articles/flex_javascript.html
0 Kudos