开发者

Adobe AIR (html/javascript): navigateToUrl's window parameter not working

have a problem navigating to a Url in the default browser in an Adobe Air project (html/javascript).

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 of the main page in a new Air application that reproduces the problem:

<html>
    <head>
        <title>navigateToURLTest</title>
        <script type="text/javascript" src="lib/air/AIRAliases.js"></script>        
    </head>
    <body>      
        <a href="#" onclick="javascript:air.navigateToURL(new air.URLRequest('http://www.adobe.com'), 'TestWindow');return false;">Same Tab</a>
    </body>
</html>

How can I 开发者_如何学Copen the url in the same window/tab?


You should have both of your anchors to have the same target specified:

<html>
    <head>
        <title>navigateToURLTest</title>
        <script type="text/javascript" src="lib/air/AIRAliases.js"></script>
    </head>
    <body>
        <a href="http://www.google.com" target="testp"
            onclick="javascript:air.navigateToURL(new air.URLRequest('http://www.adobe.com'), 
            'TestWindow');return false;">New Tab</a>
        <br />
        <a href="http://www.adobe.com" target="testp"
            onclick="javascript:air.navigateToURL(new air.URLRequest('http://www.adobe.com'), 
            'TestWindow');return false;">Same Tab</a>
    </body>
</html>

If no window with name "testp" is opened in your current list of tabs, it will open a new tab, and if you already have it, then it will be changed.


this code works for me:

navigateToURL(new URLRequest("http://www.adobe.com"), '_self');

applied to your code:

<html>
<head>
    <title>navigateToURLTest</title>
    <script type="text/javascript" src="lib/air/AIRAliases.js"></script>
</head>
<body>
    <a href="#" onclick="air.navigateToURL(new air.URLRequest('http://www.adobe.com'),'TestWindow');return false;">Same Tab</a>
</body>
</html>

Please notice two things, rekaszeru has added a link in the href ( which should not be there... same with target= ) second, the onclick event does NOT need the "javascript:"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜