Relative anchor fails when base href is set on page.
prasad83 opened this issue · 1 comments
prasad83 commented
Consider the http://site.tld/page is being viewed and is configured.
TOC link <a href="#inside-page"> would result to http://site.tld#inside-page - WRONG.
Having options... base would be good.
$("<li/>").appendTo(stack[0]).append(
$("<a/>").text(elem.text()).attr("href", (thisOptions.base ? thisOptions.base : '') + "#" + elem.attr("id"));
);
In the example page stated above, I would use
jQuery('#toc').toc({base: '/page'});
ndabas commented
This isn't an issue with this library, per se.
You can easily handle this case with some code like this:
jQuery("#toc").toc().find("a").attr("href", function (i, a) { return "/page" + a; });