0

Actionsctipt code:

on(press)
{
     getURL(escape("address.html?0"));
}

This works absolutely fine in Internet Explorer but in Chrome in the question mark is obviously made into "%3F".

Any ideas how I can stop this from happening and still keep it compatible with IE and other popular browsers?

Thanks.

Marty
  • 39,033
  • 19
  • 93
  • 162
Ryan Smith
  • 1,255
  • 2
  • 13
  • 16

2 Answers2

1

As mgraph says in his comment, you shouldn't escape the entire URL, simply do:

getURL("address.html?0");

If your real URL (guessing "address.html?0" is a simplified example) has parts that needs to be escaped, then you would want to escape those parts only, to avoid having the ? and similar being escaped. So for example like this:

var userName:String = "Lars Blåsjö";
getURL("page.html?name=" + escape(userName)); 
Lars Blåsjö
  • 6,118
  • 2
  • 19
  • 23
  • I have tried all of this, it was the first things I thought of doing when I discovered the problem. If I do not escape the Qmark it leaves it out and anything following it (in Chrome), if escape it then it converts it as I previously said to "%3F". – Ryan Smith Feb 21 '12 at 22:06
  • It sounds very strange that not escaping would leave out the question mark. I have never experienced that, or had any problems with getURL() and such URLs, in any browser. How does your URL look exactly? Is it "address.html?0" or is that just an example? – Lars Blåsjö Feb 21 '12 at 22:28
  • it's literally just letters then ".html?0" – Ryan Smith Feb 26 '12 at 15:52
  • That works perfectly without escape() in all a browsers I currently have available for testing. So again, you shouldn't need to escape anything, simply do getURL("address.html?0") – Lars Blåsjö Feb 26 '12 at 19:14
  • I know for certain it works in Internet Explorer, just not in Chrome. Did you test Chrome too? Thanks for helping by the way. – Ryan Smith Mar 02 '12 at 15:28
0

You could try the Querystring class provided by Adobe I used in this answer.

Community
  • 1
  • 1
Jason Towne
  • 8,014
  • 5
  • 54
  • 69
  • Isn't that a bit OTT for a compatibility issue? Is there not some simpler fix for this within the string? – Ryan Smith Feb 21 '12 at 22:07
  • @user1221906 I wouldn't consider it OTT if it fixes your issue, is compatible in all browsers and prevents you from having to escape special characters. It's a single class that can be easily reused throughout your app. I'm curious why you think that would be considered OTT? – Jason Towne Feb 22 '12 at 00:34