Multiple parameters in URL fragment
Asked Answered
G

1

23

Is there a standard format that allows for multiple parameters to be specified in the URI fragment? (the part after the hash #, not the query string.)

The most related information would be this question: Multiple fragment identifiers correct in URL?. The allowed characters for fragments can be found in that question as well.

Would it be acceptable to use, for instance, a semicolon to delimit multiple parameters like this:

http://example.net/page.html?q=1#param1=foo;param2=bar

Are there any unintentional behaviours that I should be aware of with this method? What if there is no such ID in the document with the value param1?

For the purposes of this question, only URIs of HTML resources are considered.

Gussie answered 19/4, 2014 at 13:13 Comment(0)
B
18

I think you should read this: http://en.wikipedia.org/wiki/Fragment_identifier#Examples

So the de-facto standard format for multiple parameters should be #param1=value1&param2=value2 You can see this way is used by Media Fragments URI 1.0 and by PDF documents. There seems to be no standard for HTML resources though as you can parse the fragment in JavaScript in any way you like. But I'd use the same format as it looks more natural being similar to the query string format. If the browser cannot find any element with id/name equal to your hash fragment, it will navigate to the beginning of the document by default.

Also browsers will consider the complete hash fragment as a possible id/name. So they will look for id/name equal to param1=value1&param2=value2 but not just param1.

Brownout answered 20/5, 2014 at 10:37 Comment(2)
Besides if you're interested in making your AJAX application crawlable by search engines, here is a guide from Google about using hash fragment #! developers.google.com/webmasters/ajax-crawling/docs/…Brownout
Thanks. Now that's deprecated webmasters.googleblog.com/2015/10/…Dre

© 2022 - 2024 — McMap. All rights reserved.