PDA

View Full Version : button open url with vars in url string


davej
05-15-2008, 04:00 PM
ok this blows I am doing the simplest of web things, using a button to open a url. the url contains get variables http://somesite.com/index.aspx?com=68&idh=1
Here is my button code

<mx:Button click="navigateToURL( new URLRequest("http://ibs.web.boeing.com/index.aspx?com=68&idh=1") )" label="LRTP / IAD" width="200" height="22"/>

it works great if there are no vars in the url or only one but if there is a second var in this case idh=1 it breaks and gives this error: " referrance to entity idh must end with the ; delimiter"

I have also tried the code from http://www.tanguay.info/web/codeExample.php?id=1011 which gives the same error.

any help would be much appriciated.

drkstr
05-16-2008, 02:22 AM
I think it's an XML parsing thing. Try setting an actionscript var that contains the URL and navigate to the the var, or just call an onButtonClick(); function that does what's in your click="".

Best Regards,
~Aaron

davej
05-16-2008, 05:53 PM
I was hopping to have inline code on the button as I have about 20 buttons and would be nice to avoid having custom as functions for each.

drkstr
05-16-2008, 08:53 PM
Don't know what to tell ya.

What's wrong with this?

<mx:Script>
<![CDATA[

private const LRTP_IAD_GATEWAY:String = "http://ibs.web.boeing.com/index.aspx?com=68&idh=1";
]]>
</mx:Script>

<mx:Button click="navigateToURL( new URLRequest(LRTP_IAD_GATEWAY) )" label="LRTP / IAD" width="200" height="22"/>

I would consider this better practice anyways. I rarely ever "hard-code" links into an app.


Best Regards,
~Aaron

box86rowh
05-16-2008, 10:29 PM
You just have to replace your &'s with the entity for & which is &amp;
that will work fine after that!

http://ibs.web.boeing.com/index.aspx?com=68&idh=1
will be
http://ibs.web.boeing.com/index.aspx?com=68&amp;idh=1