views:

473

answers:

1

I use anchors in my URLs, allowing people to bookmark 'active pages' in a web application. I used anchors because they fit easily within the GWT history mechanism.

My existing implementation encodes navigation and data information into the anchor, separated by the '-' character. I.e. creating anchors like #location-location-key-value-key-value

Other than the fact that negative values (like -1) cause serious parsing problems, it works, but now I've found that having two separator characters would be better. Also, givin the negative number issue, I'd like to ditch using '-'.

What other characters work in a URL anchor that won't interfere with the URL or its GET params? How stable will these be in the future?

+7  A: 
Daniel LeCheminant
Wouldn't your first example be interpreted as an anchor of "name", and two parameters a and b? Is that second example legal?
Paul W Homer
@Paul: No, because according to the spec, everything after the # in a url is considered to be the fragment identifier. Normal URL parameters must be encoded before the #
Daniel LeCheminant
Paul W Homer
@Paul: It's supposed to work (and from what I can tell on my machine, it does work)
Daniel LeCheminant
Paul W Homer
Keep in mind that you need also to consider what HTML allows.XHTML 1.0 deprecated a/@name in favor of a/@id, and HTML5 removes it (if I recall correctly).But, the syntax for a/@id is constrained to name characters, so many of those allowed in fragments will not be allowed there.
Julian Reschke