Skip to content

Instantly share code, notes, and snippets.

@allusis
Created February 6, 2017 20:35
Show Gist options
  • Save allusis/14ed6aff40de0935b82f95d576ed26fd to your computer and use it in GitHub Desktop.
Save allusis/14ed6aff40de0935b82f95d576ed26fd to your computer and use it in GitHub Desktop.
Anchor rebuilder when using <base>
// <base> is nice, but it ruins anchors..
// Let us rebuild him
$(document).ready(function() {
var pathname = window.location.href.split('#')[0];
$('a[href^="#"]').each(function() {
var $this = $(this),
link = $this.attr('href');
$this.attr('href', pathname + link);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment