开发者

FLEX: how to correctly pass the link to a page?

开发者 https://www.devze.com 2022-12-29 01:54 出处:网络
I\'m using <mx:LinkButton label=\"www.google.com\" click=\"navigateToURL(new URLRequest(event.curr开发者_Python百科entTarget.label.toString()))\" />

I'm using

<mx:LinkButton label="www.google.com" click="navigateToURL(new URLRequest(event.curr开发者_Python百科entTarget.label.toString()))" />

to open a browser window to display the website on the label of my LinkButton. However I cannot correctly pass the link.. you see the problem:

file://localhost/..myapp/bin-debug/www.google.com

thanks


The problem you're having is that you didn't add "http://" to the beginning. Most browsers can adjust for that because they're built to assume you mean http:// if you leave it out - but Flash Player won't adjust for that, since in theory you could be referring to a file on your hard drive or whatever.

Either add the http:// to your label or to your URLRequest.


Usually when defining links there are three ways they will be interpreted:

  • xy/file.ext is a relative reference using the current folder as the starting point. It is equivalent to ./xy/file.ext in that way.
    So when you are at http://example.com/subdirectory/index.html, it get's interpreted as http://example.com/subdirectory/xy/file.ext.
  • /xy/file.ext is a relative reference using the host's root as the starting point.
    So in the above situation the link would lead to http://example.com/xy/file.ext.
  • The other method is by specifying an absolute link. This is the solution you should use to navigate to a different host, so especially in your case where you want to link to google. Simply specify the full host with the protocol: http://google.com as the link target and it will work.


I'm suspecting that the text is something like "google.com" rather than an absolute url.

Try this:

<mx:LinkButton label="www.google.com" click="navigateToURL(new URLRequest('http://' + event.currentTarget.label.toString()))" />
0

精彩评论

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

关注公众号