jquery-archive / jquery-mobile

jQuery Mobile Framework
https://jquerymobile.com
Other
9.69k stars 2.41k forks source link

Linking to a location on the same page does not work; Bookmarking #1182

Closed jonpond closed 13 years ago

jonpond commented 13 years ago

Linking to a location on the same page does not work (aka bookmarking). Any ideas?

Example: http://www.w3schools.com/HTML/tryit.asp?filename=tryhtml_link_locations

toddparker commented 13 years ago

Are you talking about an anchor link like index.html#foo ? That works if you have multiple pages in a single html file. All pages are bookmarkable. Read more here: http://jquerymobile.com/demos/1.0a3/docs/pages/docs-pages.html

jonpond commented 13 years ago

Thanks for your feedback. Close, but I'm looking to bookmark to a section on the same page. For example, a "skip to navigation" or "skip to bottom of page" link that would appear at the top of a page and shoot you down to the designated location.

Based on the following, it appears that I will not be able to do that:

PLEASE NOTE: Since we are using the hash to track navigation history for all the Ajax 'pages', it's not currently possible to deep link to an anchor (index.html#foo) on a page in jQuery Mobile, because the framework will look for a 'page' with an ID of #foo instead of the native behavior of scrolling to the content with that ID.

Correct me, if I'm wrong.

toddparker commented 13 years ago

Yep, it's not possible. You can script it to scroll to a position, but you can't just use a anchor link because we using the hash for tracking ajax history state.

jonpond commented 13 years ago

Thanks! Any plans to build something like this in?

toddparker commented 13 years ago

It's a limitation of the browser. We need to use the hash to track pages to maintain back button support and bookmarking with Ajax navigation. Since there is only one hash, anchor links can't be supported. It's a tradeoff, but you can workaround scrolling to a position. If we could support both, we would!

jonpond commented 13 years ago

I hear ya, thanks!