javascript - URL fragments and the BASE tag -


i'm using <base> tag in application simplify development.

i'm aware of "feature" occurs when anchor url fragment, in routes <base> url + fragment.

what can circumvent that? i've never fudged window.location or in javascript, , rather hack around awhile @ it, assume knows of quick-and-dirty, or example.

can circumvented? if so, please advise.

(i hate asking questions suggest no attempt has been made, i've been searching/reading little avail)

(also; using jquery, examples take advantage of vanilla javascript or jquery welcome)


jquery solution hacked together, not sure if viable permanent solution though, thoughts?

$('a').each(function(index){     if($(this).attr('href').indexof('#') == 0){         $(this).attr('href', (window.location.href).replace(/#.*$/, '')             + $(this).attr('href'));     } }); 

ok, so, think understand question now.

this has been tested in google chrome , firefox.

add javascript @ end of body:

base=document.getelementsbytagname("base");  base=base[0].href;  links=document.getelementsbytagname('a');  for(index in links){     if(links[index].href.indexof(base+"#")==0){         links[index].href=document.location+links[index].href.slice(links[index].href.indexof("#"));     } } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -