Using multiple fragment identifiers in a url

I was wondering if I can use multiple fragment identifiers in the URL, for example: http://example.com/videos/index.html#videos#video_2

I am using jQuery Tools tabbing system on my index.html page with a history plugin. On this tab "Video" there is a Flash player and a list of videos on it. Clicking on the thumbnail of the video loads the file into the player.

I would like the visitor to be able to add bookmarks not only to the #videos tab, but also a specific video.

I think this is completely wrong if you think that you can use two fragment identifiers in the URL for this?

+4
source share
3 answers

I'm sure double snapping is not possible!

You can put the pointer on the correct tab and video in the url query string (e.g. mysite.com/videos/index.html?tab=video&video=2) and then parse this in JavaScript. Then it can be marked.

However, have you failed to use the original model (using a single # bindings binding), and then just use JavaScript to find the tab in which the tag is located, and therefore show the correct tab?

+4
source

No, you cannot use multiple hashtags in the url. The identifier after the hash characters leads to binding to the bookmark on the page, and you can go to only one anchor, you cannot go to two anchors at the same time.

If you schedule a video, it’s natural that the URL will lead to the video, and if you need to display a specific tab on the page, you must have a code that recognizes the video’s binding and shows the correct tab.

+2
source

The regular expression for parsing the URL fragment after # as follows:

 (#(.*))? 

This means that every character can be transmitted. So, choose one of these two approaches:

  • convert all hashes after the first to "% 23". also you need to do this (conversion to% HEX equiv.) for all unacceptable or reserved characters. ex: http://domain.com/app#first%23second
  • Use multiple hashes and process them in the app! The first one is simple, but cannot be implemented in your specific application.

see this document for valid characters after # .

+2
source

Source: https://habr.com/ru/post/1339352/


All Articles