dntz
dntz

Reputation: 35

How to stop the address bar dropping down in mobile browsers when URL is updated

Is there anyway to stop the address bar dropping down in mobile browsers when an anchor target extension is placed on the end of the URL?

For example when the anchor <a href="#contact"></a> is clicked the URL would update from http://www.websiteurl.com/ to http://www.websiteurl.com/#contact causing the URL bar to drop down if it isn't already visible.

Hoping there's a solution to this one!

Thanks

Upvotes: 0

Views: 143

Answers (1)

Eric Londaits
Eric Londaits

Reputation: 11

"The fact of having an anchor with an href attribute is enough for Safari Mobile to show the bar unless the address is preceded by the hash sign. It is not the fact of changing the URL, because if you preventDefault() the click on the link and avoid the navigation, the bar is shown anyway."

From: http://jmperezperez.com/prevent-iphone-navigation-bar-ajax-link-click/

That page has further explanations and code. The solution seems to be to add a click handler to links ( elements) that removes the href attribute and redirects to the page through JS.

Upvotes: 1

Related Questions