Created
February 6, 2017 20:35
-
-
Save allusis/14ed6aff40de0935b82f95d576ed26fd to your computer and use it in GitHub Desktop.
Anchor rebuilder when using <base>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <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