Tag: responsive

Safari and Hash URLs

Just discovered this strange behaviour in Safari (and Safari mobile). If you are using a cross-page url with a hash tag, first it must be formatted thus:

http://domain.tld/path/to/page/#hashtag

Note the slash before the hash. That’s apparently key to getting the hash recognized in Safari. Doesn’t seem to break in other browsers this way.
Next, the javascript to capture this is different:

//no good:
var hash = window.location.hash.replace('tab-', '');

//good:
var hash = location.hash.replace('tab-', '');

Again, this seems to work in other browsers.