Skip to main content
Participating Frequently
April 28, 2011
Question

BUG: navigateToUrl always opens new tab in browser, also when window parameter is specified

  • April 28, 2011
  • 21 replies
  • 5671 views

I have a problem navigating to a Url in the default browser in an Adobe Air project.

air.navigateToUrl(request, windowName) launches the browser and displays the page, but it displays a new tab for every request.

Here is a very simple example that shows the problem:

Flex:

<?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">

<fx:Script>

<![CDATA[

import flash.display.Sprite;

import flash.net.navigateToURL;

import flash.net.URLRequest;

protected function button1_clickHandler(event:MouseEvent):void

{

NavigateToURLExample();

}

public function NavigateToURLExample():void {

var url:String = "http://www.adobe.com";

var request:URLRequest = new URLRequest(url);

try {           

navigateToURL(request, "testWindow");

}

catch (e:Error) {

// handle error here

}

}

]]>

</fx:Script>

<fx:Declarations>

</fx:Declarations>

<s:Button x="169" y="165" label="Button" click="button1_clickHandler(event)"/>

</s:WindowedApplication>

HTML:Javascript:

<html>

    <head>

        <title>navigateToURLTest</title>

        <script type="text/javascript" src="lib/air/AIRAliases.js"></script>      

    </head>

    <body>    

        <a href="#" target="testp"  onclick="javascript:air.navigateToURL(new air.URLRequest('http://www.adobe.com'), 'TestWindow');return false;">Same Tab</a>

    </body>

</html>

How can I open the url in the same window/tab?

Message was edited by: Karel VDH

This topic has been closed for replies.

21 replies

Participant
August 8, 2011

I have seomthing like this inside a class or package

function foo(event:MouseEvent):void
            {
                var result:String = ExternalInterface.call("callHome");
                var fooURL:URLRequest = new URLRequest(result);
                navigateToURL(fooURL, "_self");
            }
           
            logoButton.addEventListener(MouseEvent.CLICK, foo);

and this on every html page

<script type="text/javascript">
function callHome(){
   
    return "http://localhost/fooproject/index.html";
}

This is a flash button of course I am not sure if it helps, but this worked out for me.

Karel_VDHAuthor
Participating Frequently
August 22, 2011

Hi Junji,

Thank you for your post.

I'm working in Air, so I there is no hosting page.

I tried launching from Actionscript in Air, but that doesn't work either.

kind regards,

Karel

Participant
May 18, 2012

Hi Karel,

I know this post is kind of old, but were you able to find a workaround? I'm having the exactly same problem in Adobe AIR.

Thanks,

Marcio

Participant
June 29, 2011

Hello All,

I am able to open pdf using navigateToURL method.

But the title of the web page/tab shows the entire url... is there any way to change the title of the page/tab to something else?

any help is appreciated

Thanks

Karel_VDHAuthor
Participating Frequently
May 11, 2011

Hi,

I tested this also in an Air Flex application - I updated the original post accordingly.

The same problem occurs in FLex.

Does anyone have a workaround?

I must open the web page in the default browser, in the same tab.

Participant
June 6, 2011

Hi..

I am struck with the same issue as well.

It works for few sites like "http://www.adobe.com" and "http://www.google.com", but most of the sites open up in a new window, even if I specify custom name, like:

navigateToURL(new URLRequest("http://www.britishairways.co.uk"), "MyWindow");

Also tried through ExternalInterface viz:

ExternalInterface.call("window.open", new URLRequest("http://www.britishairways.co.uk"), "MySameWindow", "");

Please reply whether it is a bug, or there if there are any alternative approaches.

chris.campbell
Legend
June 9, 2011

I'll ask around about this behavior and see if I can get additional info.  In the meantime, would you mind creating a new bug on our online bug database?  Please post back with a URL so others can comment and add their votes.

Thanks,
Chris